Results 1 to 7 of 7

Thread: Need WebService to get Contact details

  1. #1
    sugarAdam is offline Sugar Community Member
    Join Date
    Dec 2011
    Location
    New York
    Posts
    37

    Default Need WebService to get Contact details

    Hello Community, My Sugar CRM Version is Enterprise 6.2.2:

    I'm hoping that there's some existing functionality that I can leverage in a custom application.

    I would imagine that a Web service is required to make it work, but in a nutshell, here's what I'm looking for:

    When a user is creating a New Opportunity, they can select a Contact Person (on the "Contacts" tab).

    Once they have selected a Contact Name from the search results, the dialog of "Search Contacts" is dismissed.

    I believe the current functionality returns the name of the contact, and their contact ID.

    I'd like to use this contact ID, and (via jQuery / AJAX, or other means) get the Contact's Details, such as Address (Primary) to "flow" into another part of the page. I mention jQuery and AJAX because it needs to respond to when a user selects an alternate contact.

    So, if (given a Contact ID) - is there a web service that I can call from the front-end/DOM that can access details of a Contact based on said ID?

    Thanks,
    Adam

  2. #2
    sts's Avatar
    sts
    sts is offline Sugar Community Member
    Join Date
    Aug 2010
    Posts
    978

    Default Re: Need WebService to get Contact details

    SugarCRM has a SOAP/REST interface. You should have a look into the developer's guide which is available here for example: Sugar Community Edition Documentation | Open Source Business & Social CRM - SugarCRM

    You'll find there a chapter describing the web services with their parameters, especially 'get_entry' which retrieves data from Sugar objects. In your Sugar source directory service/example there are some examples.
    Stefan Ulrich Sauer
    System Analyst

    Devoteam Danet GmbH
    Gutenbergstraße 10
    D-64331 Weiterstadt
    Germany
    email: Stefan-Ulrich.Sauer@devoteam.com
    http://www.devoteam.de

  3. #3
    sugarAdam is offline Sugar Community Member
    Join Date
    Dec 2011
    Location
    New York
    Posts
    37

    Default Re: Need WebService to get Contact details

    Thanks Stefan, that link was definitely a good starting point.

    However, are there any simpler-to-follow examples? I found the 2 sample files /service/example/example.html and /service/example/test.html to be somewhat difficult to follow. Here are the steps I took.

    First, I logged in to my instance of Enterprise 6.2.2, then I replaced "index.php?etc_query_string_stuff" with service/example/test.html and got many connection errors.

    In many instances within "test.html" I had to replace
    YAHOO.util.Connect.asyncRequest('POST', 'v2/rest.php' ,
    with
    YAHOO.util.Connect.asyncRequest('POST', '../v2/rest.php' , and then, still there was (1) 404 not found following that. But I can live with that since it's an example file.

    The othe issue I'm experiencing is that in the javascript console, is that
    a) could not log in - therefore could not establish a session
    b) did not retrieve any data - most likely derived from not logging in.

    Are there parameters I should be changing by default? I would think that I would just
    need to change the service URL (subsititutnig web host for 'localhost').
    And for the objects it requests, are they pre-set community database objects and ids?
    Should I be finding a real-world example from my installation's db instance?

    Lastly, the Developer Guide PDF discussed entry points, and seemed 'disconnected'
    (in theory) with the files found in the "service/examples" directory. Do I really create standalone
    .html files to get data from web services?

    When running "example.html" I got JSONparse error as pasted in below
    Error: parseJSON
    Source File: http://yui.yahooapis.com/2.6.0/build/json/json-min.js
    Line: 7

    Code:
    YAHOO.lang.JSON=(function(){var l=YAHOO.lang,_UNICODE_EXCEPTIONS=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,_ESCAPES=/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,_VALUES=/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,_BRACKETS=/(?:^|:|,)(?:\s*\[)+/g,_INVALID=/^[\],:{}\s]*$/,_SPECIAL_CHARS=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,_CHARS={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"};function _revive(data,reviver){var walk=function(o,key){var k,v,value=o[key];if(value&&typeof value==="object"){for(k in value){if(l.hasOwnProperty(value,k)){v=walk(value,k);if(v===undefined){delete value[k];}else{value[k]=v;}}}}return reviver.call(o,key,value);};return typeof reviver==="function"?walk({"":data},""):data;}function _char(c){if(!_CHARS[c]){_CHARS[c]="\\u"+("0000"+(+(c.charCodeAt(0))).toString(16)).slice(-4);}return _CHARS[c];}function _prepare(s){return s.replace(_UNICODE_EXCEPTIONS,_char);}function _isValid(str){return l.isString(str)&&_INVALID.test(str.replace(_ESCAPES,"@").replace(_VALUES,"]").replace(_BRACKETS,""));}function _string(s){return'"'+s.replace(_SPECIAL_CHARS,_char)+'"';}function _stringify(h,key,d,w,pstack){var o=typeof w==="function"?w.call(h,key,h[key]):h[key],i,len,j,k,v,isArray,a;if(o instanceof Date){o=l.JSON.dateToString(o);}else{if(o instanceof String||o instanceof Boolean||o instanceof Number){o=o.valueOf();}}switch(typeof o){case"string":return _string(o);case"number":return isFinite(o)?String(o):"null";case"boolean":return String(o);case"object":if(o===null){return"null";}for(i=pstack.length-1;i>=0;--i){if(pstack[i]===o){return"null";}}pstack[pstack.length]=o;a=[];isArray=l.isArray(o);if(d>0){if(isArray){for(i=o.length-1;i>=0;--i){a[i]=_stringify(o,i,d-1,w,pstack)||"null";}}else{j=0;if(l.isArray(w)){for(i=0,len=w.length;i<len;++i){k=w[i];v=_stringify(o,k,d-1,w,pstack);if(v){a[j++]=_string(k)+":"+v;}}}else{for(k in o){if(typeof k==="string"&&l.hasOwnProperty(o,k)){v=_stringify(o,k,d-1,w,pstack);if(v){a[j++]=_string(k)+":"+v;}}}}a.sort();}}pstack.pop();return isArray?"["+a.join(",")+"]":"{"+a.join(",")+"}";}return undefined;}return{isValid:function(s){return _isValid(_prepare(s));},parse:function(s,reviver){s=_prepare(s);if(_isValid(s)){return _revive(eval("("+s+")"),reviver);}throw new SyntaxError("parseJSON");},stringify:function(o,w,d){if(o!==undefined){if(l.isArray(w)){w=(function(a){var uniq=[],map={},v,i,j,len;for(i=0,j=0,len=a.length;i<len;++i){v=a[i];if(typeof v==="string"&&map[v]===undefined){uniq[(map[v]=j++)]=v;}}return uniq;})(w);}d=d>=0?d:1/0;return _stringify({"":o},"",d,w,[]);}return undefined;},dateToString:function(d){function _zeroPad(v){return v<10?"0"+v:v;}return d.getUTCFullYear()+"-"+_zeroPad(d.getUTCMonth()+1)+"-"+_zeroPad(d.getUTCDate())+"T"+_zeroPad(d.getUTCHours())+":"+_zeroPad(d.getUTCMinutes())+":"+_zeroPad(d.getUTCSeconds())+"Z";},stringToDate:function(str){if(/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})Z$/.test(str)){var d=new Date();d.setUTCFullYear(RegExp.$1,(RegExp.$2|0)-1,RegExp.$3);d.setUTCHours(RegExp.$4,RegExp.$5,RegExp.$6);return d;}return str;}};})();YAHOO.register("json",YAHOO.lang.JSON,{version:"2.6.0",build:"1321"});
    Sorry to sound so confused,
    Adam
    Last edited by sugarAdam; 2012-02-07 at 07:41 PM. Reason: Adding parseJSON errors

  4. #4
    sts's Avatar
    sts
    sts is offline Sugar Community Member
    Join Date
    Aug 2010
    Posts
    978

    Default Re: Need WebService to get Contact details

    I had a look into my notes concerning SOAP/REST interface and found two things to mention. Not sure if they fix all your problems but I had to do small changes to get it to work:

    1)
    SOAP examples starting with
    PHP Code:
    <?php
    if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
    are wrong. This should be:
    PHP Code:
    <?php
    if(!defined('sugarEntry'))define('sugarEntry'true);
    because normally this SOAP interface won't be called from inside Sugar and in that case the script will "die" before doing what it is expected to do ...

    2)
    .htaccess file in main Sugar directory defines something like this:

    PHP Code:
    RedirectMatch 403 (?i)/+(soap|cache|xtemplate|data|examples|include|log4php|metadata|modules)/+.*.(php|tpl
    This restricts the access to those Sugar files that usually shouldn't be called from outside.
    "examples|" has to be removed if you want to start the example files from their normal directory. Otherwise the web server will redirect the call to that page with an error page '403'.
    Stefan Ulrich Sauer
    System Analyst

    Devoteam Danet GmbH
    Gutenbergstraße 10
    D-64331 Weiterstadt
    Germany
    email: Stefan-Ulrich.Sauer@devoteam.com
    http://www.devoteam.de

  5. #5
    sugarAdam is offline Sugar Community Member
    Join Date
    Dec 2011
    Location
    New York
    Posts
    37

    Default Re: Need WebService to get Contact details

    Again Stefan, I thank you, but what I think would help here,
    and not just "help me" (but help many others I'm sure) is a concrete,
    step-by-step tutorial on how (and where) to create the necessary files in an upgrade-safe manner.

    A tutorial (end-over-end) for both SOAP and REST Implementations. For me, preference on RESTful interface.

    The Developer guide PDF does not have (or at least does not "seem" to have
    a step-by-step sample guide).

    I've been googling on tutorials for this, and I should say that good, solid examples and tutorials are not easy to find. Sigh.

    Thanks for all your help and feedback though.
    Adam

  6. #6
    sts's Avatar
    sts
    sts is offline Sugar Community Member
    Join Date
    Aug 2010
    Posts
    978

    Default Re: Need WebService to get Contact details

    I agree with you, Adam. The developer guide for web services could be much better ...

    One link that was helpful for me is this one: SugarCRM Web Services. API | SugarTalk -
    It is Russian, but Google Chrome translated this for me into English ... This article includes some useful links too, e.g. to this small tutorial from John Mertic: Being RESTful with SugarCRM

    EDIT: found a forum's thread discussing some mistakes in the last mentioned article and how to fix them: http://www.sugarcrm.com/forums/f148/...example-66280/
    Last edited by sts; 2012-02-07 at 09:44 PM.
    Stefan Ulrich Sauer
    System Analyst

    Devoteam Danet GmbH
    Gutenbergstraße 10
    D-64331 Weiterstadt
    Germany
    email: Stefan-Ulrich.Sauer@devoteam.com
    http://www.devoteam.de

  7. #7
    sugarAdam is offline Sugar Community Member
    Join Date
    Dec 2011
    Location
    New York
    Posts
    37

    Default Re: Need WebService to get Contact details

    Thanks Stefan, I'll check through it tomorrow. Have a great evening and thanks for all your help.
    Adam

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. upload a picture to a contact via Webservice SDK
    By susannesch in forum Developer Help
    Replies: 1
    Last Post: 2011-02-23, 08:32 PM
  2. Manually adding contact details?
    By Adam Dynamic in forum Help
    Replies: 5
    Last Post: 2010-12-20, 03:51 PM
  3. Restricting the view of contact details
    By Vibhav in forum Help
    Replies: 0
    Last Post: 2007-09-20, 10:40 AM
  4. Email contact details to someone
    By Proware in forum Help
    Replies: 0
    Last Post: 2006-08-21, 04:38 AM
  5. Missing Contact Details
    By jackwhittaker2000 in forum Help
    Replies: 1
    Last Post: 2006-05-24, 08:23 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •