SugarCRM SOAP: Difference between revisions

From Starfish ETL
Jump to navigation Jump to search
(Created page with "=SugarCRM REST Origin= ==Sample Origin Filters== See the GET /<module> filterList in the SugarCRM REST Help: https://SERVER/rest/v10/help/ Note the [{...}] surrounding the f...")
 
 
(6 intermediate revisions by the same user not shown)
Line 1: Line 1:
=SugarCRM REST Origin=
=SugarCRM SOAP Origin=
Note that the tab in Starfish is labelled simply "SugarCRM".
 
==Sample Origin Filters==
==Sample Origin Filters==
See the GET /<module> filterList in the SugarCRM REST Help:  https://SERVER/rest/v10/help/


Note the [{...}] surrounding the filterThis is required.
=Mapping=
 
==Attachments==
<syntaxhighlight lang="c">
In Sugar, Attachments are stored as Notes.  To attach a file to a Note, simply run and Insert, Update or Update/Insert Stage against the Notes module. There will be a field call Attachment. Map it as a function and select the Format Conversion Tab in the Function Field window. Fill in your Conversion Source where the file can be foundEX: C:\Temp\SugarCRM\SugarCRM\cache\upload\@@ORG:id@@.  Then select the File -to- Base64 Conversion Operation.
[{"id":"84b1c05c-1043-05c8-ced8-53a2ed18427b"}]
</syntaxhighlight>
 
A more complex filter using $not_null and $not_equals:
 
<syntaxhighlight lang="c">
[{"$or":[{"import_source_id_c":{"$not_null":""}},{"import_source_id_c":{"$not_equals":""}}]}]
</syntaxhighlight>
 
Note that the $not_null operation still requires a blank string.
 
Checking to see if a field is blank using $is_null:
<syntaxhighlight lang="c">
[{"status_c":{"$is_null":""}}]
</syntaxhighlight>


=Mapping=
==Field Types==
==Field Types==
===Date Fields===
<syntaxhighlight lang="vb">
Function ScriptedField
  ScriptedField=FormatDate("@@ORG:renewal_date_c@@", "yyyy-MM-dd")
End Function
</syntaxhighlight>
===Datetime Fields===
<syntaxhighlight lang="vb">
Function ScriptedField
  ScriptedField=FormatDate("@@ORG:date_entered@@", "yyyy-MM-ddTHH:mm:ss")
End Function
</syntaxhighlight>
===Multi-select Dropdowns===
===Multi-select Dropdowns===
Data in Multiselect Dropdowns is stored as a comma separated string with carats around each value:
Data in Multiselect Dropdowns is stored as a comma separated string with carats around each value:
Line 63: Line 34:
End Function
End Function
</syntaxhighlight>
</syntaxhighlight>
===Checkbox===
When mapping to a checkbox, use a script to set the value to "true" or "false", making sure to use all lowercase.  (Needs verification.)


==VBScript==
==VBScript==
===Smart Lookup===
===Smart Lookup===
When filtering in a smart lookup, the filter must use double-double quotes:
When filtering in a Smart Lookup, the make sure to put single quotes around the query value:


<syntaxhighlight lang="vb">
<syntaxhighlight lang="vb">
strSugarID = SmartLookup("Accounts","id","[{""import_source_id"":""84b1c05c-1043-05c8-ced8-53a2ed18427b""}]")
ScriptedVariable = SmartLookup("Accounts", "id", "accountid_c='@@ORG:ACCOUNTID@@'")
</syntaxhighlight>
</syntaxhighlight>


A more complex filter:
===SugarGetRelationship===
<syntaxhighlight lang="vb">
Use this function to get the records related to another record.  For example, the Contacts related to a phone call.  In the example below, I loop through the returned records, split them into an array, convert them to foreign IDs and finally put them into a comma separated string.
res = SmartLookup("Users", "id", "[{""$and"":[{""last_name"":""@@ORG:IENSalesRep_Last@@""},{""first_name"":""@@ORG:IENSalesRep_First@@""}]}]")
<source lang="vb">
</syntaxhighlight>
'Get related contacts from Sugar
strContactIDs = SugarGetRelationships("Calls", "@@ORG:id@@", "Contacts")
LogMessage "ContactIDs: " & strContactIDs
'Put list into Array
arrContactIDs = split(strContactIDs, ",")
numContactUpperBound = UBound(arrContactIDs)
'Convert SugarIDs to foreignIDs
For i = 0 To numContactUpperBound
arrContactIDs(i) = XrefRead("contacts_sugar_to_other", arrContactIDs(i))
Next
'Create a comma seperated string of Depos IDs
strContactIDs = Join(arrContactIDs, ",")
</source>


=Sugar Specific=
=Sugar Specific=

Latest revision as of 18:50, 13 October 2015

SugarCRM SOAP Origin

Note that the tab in Starfish is labelled simply "SugarCRM".

Sample Origin Filters

Mapping

Attachments

In Sugar, Attachments are stored as Notes. To attach a file to a Note, simply run and Insert, Update or Update/Insert Stage against the Notes module. There will be a field call Attachment. Map it as a function and select the Format Conversion Tab in the Function Field window. Fill in your Conversion Source where the file can be found. EX: C:\Temp\SugarCRM\SugarCRM\cache\upload\@@ORG:id@@. Then select the File -to- Base64 Conversion Operation.

Field Types

Multi-select Dropdowns

Data in Multiselect Dropdowns is stored as a comma separated string with carats around each value: ^Atari^,^Automobiles^,^Baseball^,^Fine_Art^,^Running_Walking^

Sample Function:

Function ScriptedField
  dim cat 
  cat = "@@ORG:Categories@@"
  dim res
  If InStr(cat,"Board Invitee") Then
    res = res & "^Board_Invitee^,"
  End If
  If InStr(cat,"Priority Contact") Then
    res = res & "^Priority_Contact^,"
  End If
  If InStr(cat,"Dividend Contact") Then
    res = res & "^Dividend_Contact^,"
  End If
  If Right(res,1) = "," Then
    res = Left(res,Len(res)-1)
  End If
  ScriptedField=res
End Function

VBScript

Smart Lookup

When filtering in a Smart Lookup, the make sure to put single quotes around the query value:

ScriptedVariable = SmartLookup("Accounts", "id", "accountid_c='@@ORG:ACCOUNTID@@'")

SugarGetRelationship

Use this function to get the records related to another record. For example, the Contacts related to a phone call. In the example below, I loop through the returned records, split them into an array, convert them to foreign IDs and finally put them into a comma separated string.

'Get related contacts from Sugar
strContactIDs = SugarGetRelationships("Calls", "@@ORG:id@@", "Contacts")
LogMessage "ContactIDs: " & strContactIDs
'Put list into Array
arrContactIDs = split(strContactIDs, ",")
numContactUpperBound = UBound(arrContactIDs)
'Convert SugarIDs to foreignIDs
For i = 0 To numContactUpperBound
	arrContactIDs(i) = XrefRead("contacts_sugar_to_other", arrContactIDs(i))
Next
'Create a comma seperated string of Depos IDs
strContactIDs = Join(arrContactIDs, ",")

Sugar Specific

Warnings

SmartLookups and Origin Filters against the User Module fail.

SQL Statements to Purge Data From Sugar

delete from accounts;
delete from accounts_audit;
delete from accounts_contacts;
delete from accounts_cstm;
delete from accounts_opportunities;

delete from activities;
delete from activities_users;

delete from bugs;
delete from bugs_cstm;

delete from calls;
delete from calls_contacts;
delete from calls_users;

delete from cases;
delete from cases_audit;

delete from contacts;
delete from contacts_audit;
delete from contacts_cstm;
delete from contacts_users;

delete from emails;
delete from emails_text;
delete from emails_beans;
delete from email_addr_bean_rel where bean_module <> 'Users';
delete from email_addresses where id in (select email_address_id from email_addr_bean_rel where bean_module <> 'Users');

delete from job_queue;

delete from meetings;
delete from meetings_contacts;
delete from meetings_leads;
delete from meetings_users;

delete from notes;

delete from opportunities;
delete from opportunities_contacts;
delete from opportunities_cstm;
delete from opportunities_audit;

delete from outbound_email;

delete from products;

delete from tasks;