Changes

Creating SmartConnect Functions

9,703 bytes added, 15:01, 23 June 2023
Delete Multiple Upload Files
{{Banner-UnderConstruction}}
SmartConnect functions are specific to individual copies of SmartSimple so you can only use the functions that are have been previously established in that copy. The article describes how you add functions to an instance.
'''Field List'''  - companies.*
No parameters are needed to retrieve metadata.
 
[[File:APIFunctionGetOrgMeta.PNG|800px]]
'''Field List'''  - contacts.*<br />
No parameters are needed to retrieve metadata.
 
[[File:APIFunctionGetUserMeta.PNG|800px]]
'''Function Name'''  -  3.03.1 Get Method Sample 1: Retrieve a Single Organization Record<br />
'''Description'''  - This function will retrieve a single record from the organization using the recordid: [[Determining_the_companyid|Company ID]]. The function is set up to retrieve the fields listed under '''Field List'''.
 
'''Object Type'''  -  Company<br />
: '''''sample3:'''''
: An example query with brackets: ( (cf_somefield1 like '%whatever%' or cf_somefield2 like  '%whatever%'  or cf_somefield3 like  '%whatever%'  or cf_somefield4like  '%whatever%' ) and (cf_someotherfield1='whatever' or cf_someotherfield2='whatever else'))
: criteria: [{ "andor": "(", "field": "cf_somefield1", "operator": "like", "value": "whatever" },{ "andor": "or", "field": "cf_somefield2", "operator": "like", "value": "whatever" },{ "andor": "or", "field": "cf_somefield3", "operator": "like", "value": "whatever" },{ "andor": "or", "field": "cf_somefield4", "operator": "like", "value": "whatever" },{ "andor": ") and (", "field": "cf_someotherfield1", "operator": "=", "value": "whatever" },{ "andor": "or", "field": "cf_someotherfield2", "operator": "=", "value": ""whatever else" }]
: sortby: 
: othersettings : {"getstorevalue":"0","keyformat":"0"}
'''Mandatory fields''' to add new records:<br/>
objectid -  is the [[Determining_the_opportunityid|Opportunity ID]] where the user will be associated to.<br/>
contactid - [[Determining_the_userid|User ID]]<br/>rolename / roleid -  association role of the user<br/>isupdate -  "1" for yes to update and "0" for to add new record <br/>  
Parameter Sample#1<br />
--Begin custom parameter --<br />
--Begin custom parameter --<br />
jsonrset : [{"recordid":"10697883","contacts":[{"isupdate":"1","contactid":"88435720","associationid":"2829620" ,"rolename":"Signee Internal", "cf_My customfield": "updated value"}]}]<br />
--End custom parameter--
fieldid: 1523157<br />
--End custom parameter--<br />
Note: In the API website, the content of the file will be shown in the Response section as seen below.<br />[https://api.smartsimple.com/API/1/report/?url=https://api.smartsimple.com/API/1/report/&companyid=825646&alias=api&username=dataimport@smartsimple.com&password=smartsimple1&apitoken=W0t2dV58fmZGR1lzUmVDc2xibnd8BEdfAgMBAg~~&filename=Test.txt&objectid=1688407&fieldid=1523157| Click here to download the file]
[[File:APIFunctionDownloadFile1.PNG|800px]]
====Upload File(s) to a field in the company profile====
<!--122516 - API file upload-->
'''Function Name'''  -  3.06.2 Upload File Method Sample 1: Upload file(s) to an existing company record<br />
'''Description'''  - Upload the file based on the criteria indicated.<br />
'''Object Type'''  -  Company<br />
'''Action Type '''  -  Upload Files<br />
'''Field List'''  -  cf_123456
'''
 Mandatory fields''' to upload a file:
objectid - is the [wiki/Determining_the_companyid Company ID] where the file is attached to.<br />
fieldid - [wiki/Custom_Field_ID Custom Field ID] of the Organization record that is either a [wiki/Custom_Field_Type:_Upload_-_Single_File_Storage single file type] or [wiki/Custom_Field_Type:_Upload_-_Multiple_Files_Storage multiple file type].
--Begin custom parameter --<br />
objectid: 1688407<br />
fieldid: 1523157<br />
--End custom parameter--
<br />Note: To test use Postman.
The API URL for upload file will be:
https://alias.smartsimple.com/API/1/company/?alias=xxxxx&companyid=xxxxxx&username=xxxxx&password=xxxxx&apitoken=xxxxx&objectid=xxxxx&fieldid=xxxxx<br />with the file included in the form data, use POST method.
===Search File===
This function will retrieve a list of files by searching for a keyword.
jsonrset : [{"recordid":"1924628"}]<br />
--End custom parameter--
 
[[File:Delete_org.PNG|800px]]
 
====Delete a Single Contact Record====
'''Function Name'''  -  3.09.2 Delete Contact Record<br />
[[File:APIFunctionDeleteL1User.PNG|800px]]
 
====Delete Multiple Upload Files====
<!-- 138847 - API function to delete files -->
After the July 2023 upgrade, new function to delete files from Upload - Multiple Files Storage fields was added.
'''Function Name'''  -  3.09.6 Delete Files in Level One<br />
'''Description'''  - Delete existing files from a multiple file field in [[Category:Universal_Tracking_Application|Universal Tracking Application]] Level 1 record<br />
'''Object Type'''  -  Submission Manager - Grant<br />
'''Action Type '''  -  Files - Delete<br />
'''Field List'''  - cf_multiplefilefield
 
 
<u>'''Sample'''</u><br/>
'''Description'''  - To delete existing files from a multiple file field in Submission Manager Level 1<br/>
'''Mandatory fields'''<br/>
objectid -  is the [[Universal Tracking Application]] Level 1 id (opportunityid) where the file to be deleted is located.<br/>
fieldid -  the field id of the multiple file field<br/>
filename -  the filename of the file to be deleted
 
--Begin custom parameter --<br />
jsonrset : [{"objectid":"1223454","fieldid":"3163245","filename":"147807_dup.png"},{"objectid":"1223454","fieldid":"2697568","filename":"128895.png"}]<br />
--End custom parameter--
===Transaction===
<!--72195 - SmartConnect Function on Transaction Applied to prod for May 2019 Upgrade-->
* <span style="color: #ff0000;">Available after May 2019 upgrade.</span>
 * Transaction should be [[Transaction_Attribution|configured]] before using this API function. Transactions can be attached to an object (Organization or User or UTA L1/L2).
====Get Transaction Record====
=====Create or Update Transaction Record in Submission Manager L1=====
<u>'''Sample A''' - creating new transaction record from API v1</u><br/>
'''Function Name'''  -  3.10.3.2 Create or Update Transaction Record in Submission Manager L1<br />
'''Description'''  - Create new transaction record attached to a Submission Manager L1 record <br />
[[File:TransactionUpdate.PNG|800px]]
 
<u>'''Sample B''' - creating new transaction record in Submission Mgr L1 from API v2</u><br/>
<!--134010 - SmartConnect API link and unlink transactions from Objects-->
 
'''Function Name'''  -  3.10.3.2  Create or Update Transaction Record in Submission Manager L1 (API v2)<br />
'''Description'''  - Create new transaction record attached to a Submission Manager L1 record <br />
'''Object Type'''  -  Submission Manager - Transactions<br />
'''Action Type '''  - Update<br />
'''Field List'''  -  sf_Object ID;;sf_Subject;;sf_Status;;sf_Type;;cf_Remarks;;
 
Note that translevel is new in version 2 where translevel=1 for UTA L1 and translevel=2 for UTA L2.
 
'''Mandatory fields''' to add a new transaction record:<br/>
recordid -  the unique identifier from the transaction table. To create new record, recordid should be '0'<br/>
sf_Object ID -  is the object(UTA L1) the transaction would be attached to.<br/>
sf_Type -  [[Transaction_Custom_and_Standard_Field_Types|Transaction Type]] of the transaction record.<br/>
sf_Status - [[Transaction_Status|Transaction Status]] of the transaction record.<br/>
translevel -  is the UTA Level (UTA L1/L2) the transaction would be attached to. <span style="color: #ff0000;">(NEW that is implemented in API v2)</span>
 
 
--Begin custom parameter --<br />
jsonrset : [{"recordid":"0","sf_Object ID":"10697883","sf_Type":"2119","sf_Status":"82626","translevel":"1","sf_Subject":"Test Transaction Record"}]<br />
--End custom parameter--
 
'''<span style="color: #ff0000;">New Endpoint</span>: '''/API/2/transactions/
 
[[File:Transactions_01.png|800px]]
 
 
<u>'''Sample C''' - creating new transaction record in Submission Mgr L2 from API v2</u><br/>
<!--134010 - SmartConnect API link and unlink transactions from Objects--><br/>
 '''Function Name'''  -  3.10.3.2 Create or Update Transaction Record in Submission Manager L2 (API v2)<br/>
 '''Description'''  - Create new transaction record attached to a Submission Manager L2 record<br/>
 '''Object Type'''  -  Submission Manager - Transactions<br/>
 '''Action Type '''  - Update<br/>
 '''Field List'''  -  sf_Object ID;;sf_Subject;;sf_Status;;sf_Type;;cf_Remarks;;<br/>
 
Note that translevel is new in version 2 where translevel=1 for UTA L1 and translevel=2 for UTA L2.<br/>
 
'''Mandatory fields''' to add a new transaction record:<br/>
recordid -  the unique identifier from the transaction table. To create new record, recordid should be '0'<br/>
sf_Object ID -  is the object(UTA L2) the transaction would be attached to.<br/>
sf_Type -  [[Transaction_Custom_and_Standard_Field_Types|Transaction Type]] of the transaction record.<br/>
sf_Status - [[Transaction_Status|Transaction Status]] of the transaction record.<br/>
translevel -  is the UTA Level (UTA L1/L2) the transaction would be attached to. <span style="color: #ff0000;">(NEW that is implemented in API v2)</span><br/>
 
--Begin custom parameter --<br/>
 jsonrset : [{"recordid":"0","sf_Object ID":"10697974","sf_Type":"2184","sf_Status":"82626","sf_Subject":"Test Transaction Record","translevel":"2"}]<br/>
 --End custom parameter--<br/>
 
'''<span style="color: #ff0000;">New Endpoint</span>: '''/API/2/transactions/<br/>
 
[[File:Transactions_02.png|800px]]
====Delete Transaction Record====
[[File:TransactionDelete1.PNG|800px]]
 
 
 
====Link/Unlink Transaction Record from other objects====
<!--134010 - SmartConnect API link and unlink transactions from Objects-->
This new feature to link/unlink transactions is only available in APIv2 and only for L1 & L2 transactions.
 
 
<u>'''Sample A - Link existing transactions to an existing L1'''</u><br/>
'''Function Name'''  -   Link transaction record to an existing Submission Manager L1<br data-attributes="%20/">
 '''Description'''  - Link existing company transaction record to an existing Submission Manager L1 record<br data-attributes="%20/">
 '''Object Type'''  -  Submission Manager - Transactions<br data-attributes="%20/">
 '''Action Type '''  - Link / Unlink<br data-attributes="%20/">
 '''Field List'''  -  cf_5469887
 
'''Mandatory fields''' 
sf_Object ID -  is the object(UTA L1 id) the transaction would be attached to. <br/>
translevel -  level in the UTA to link the transaction to.<br/>
sf_ transaction id -  is the existing transaction record id.<br/>
islink -  indicates to link the transaction to a record.<br/>
cf_5469887 -  transaction custom field.<br/>
 
--Begin custom parameter --<br/>
 jsonrset : [{"recordid":"0","sf_Object ID":"1123456","translevel":"1","cf_5469887":"Test linking Transaction to SML1","sf_transaction id":"6165326","islink":"1"}]<br/>
 --End custom parameter--<br/>
 
<u>'''Sample B - Unlink existing transactions to an existing L1'''</u><br data-attributes="/">
 '''Function Name'''  -   Unlink transaction record to an existing Submission Manager L1<br/>
  '''Description'''  - Unlink existing company transaction record from the Submission Manager L1 record<br/>
  '''Object Type'''  -  Submission Manager - Transactions<br/>
  '''Action Type '''  - Link / Unlink<br/>
  '''Field List'''  -  
 
'''Mandatory fields'''<br/>
sf_Object ID -  is the object(UTA L1 id) the transaction would be attached to.<br/>
translevel -  level in the UTA to link the transaction to.<br/>
sf_ transaction id -  is the existing transaction record id.<br/>
unlink -  indicates to link the transaction to a record.<br/>
 
--Begin custom parameter --<br/>
  jsonrset : [{"sf_Object ID":"1123456","translevel":"1","sf_transaction id":"6165326","unlink":"1"}]<br/>
--End custom parameter--<br/>
 
<u>'''Sample C - Link existing transactions to an existing L2'''</u><br data-attributes="/">
 '''Function Name'''  -   Link transaction record to an existing Submission Manager L2<br/>
  '''Description'''  - Link existing company transaction record to an existing Submission Manager L2 record<br/>
  '''Object Type'''  -  Submission Manager - Transactions<br/>
  '''Action Type '''  - Link / Unlink<br/>
  '''Field List'''  -  cf_5469887
 
'''Mandatory fields''' <br/>
sf_Object ID -  is the object(UTA L2 id) the transaction would be attached to.<br/>
translevel -  level in the UTA to link the transaction to.<br/>
sf_ transaction id -  is the existing transaction record id.<br/>
islink -  indicates to link the transaction to a record.<br/>
cf_5469887 -  transaction custom field.<br/>
 
--Begin custom parameter --<br/>
  jsonrset : [{"recordid":"0","sf_Object ID":"50268865","translevel":"2","cf_5469887":"Test linking Transaction to SML2","sf_transaction id":"6165326","islink":"1"}]<br/>
--End custom parameter--<br/>
 
<u>'''Sample D - Unlink existing transactions to an existing L2'''</u><br/>
 '''Function Name'''  -   Unlink transaction record to an existing Submission Manager L2<br/>
  '''Description'''  - Unlink existing company transaction record from the Submission Manager L2 record<br/>
  '''Object Type'''  -  Submission Manager - Transactions<br/>
  '''Action Type '''  - Link / Unlink<br/>
  '''Field List'''  -  
 
'''Mandatory fields''' <br/>
sf_Object ID -  is the object(UTA L2 id) the transaction would be attached to.<br/>
translevel -  level in the UTA to link the transaction to.<br/>
sf_ transaction id -  is the existing transaction record id.<br/>
unlink -  indicates to link the transaction to a record.<br/>
 
--Begin custom parameter --<br/>
  jsonrset : [{"sf_Object ID":"50268865","translevel":"2","sf_transaction id":"6165326","unlink":"1"}]<br/>
--End custom parameter--<br/>
===UTA Consumer/Provider===
Smartstaff
1,385
edits