Difference between revisions of "System Call"

From SmartWiki
Jump to: navigation, search
 
(65 intermediate revisions by 7 users not shown)
Line 1: Line 1:
System Call ( embedded in browser script custom field type )
+
==System Call Overview==
 +
The System Call feature of SmartSimple provides you with the ability to execute pre-defined system functions on the server and in the process avoid the creation of client side [[Custom Field Type: Special – Browser Script|scripting]]. The benefits of System Calls are as follows:
  
<br/>Trigger Type
+
* Better performance and security as the execution of the code takes place on the server not in the client [[browser]].
 +
* More stable, as the System Calls are programmed by SmartSimple and optimized for the platform.
 +
* You don’t need to know [[JavaScript]] in order to use the feature.
  
<br/>on Load - SysCall is carried out by server  when page is requested(no javascript is required)
+
==Using System Calls==
<br/>on Page - SysCall is trigger by clicking a button on page
+
When using system calls you add the System Call references to a [[Custom Field Type: Special – Browser Script|Browser Script]] custom field. The syntax for each System Call is as follows:
<br/>on Save - SysCall is carried out by server  when page is saved(no javascript is required)
 
  
<br/>Example :
+
<pre style="white-space: -o-pre-wrap; word-wrap: break-word;"><!--SysCall_function(@parameter 1@,@parameter 2@,@parameter N@)--></pre>
  
 +
'''Note: ''' Multiple System calls can be embedded in the same script field.
  
 +
==Triggering System Calls==
 +
The execution of the System Call is controlled by the trigger that you set for the [[Custom Field Type: Special – Browser Script|Browser Script]] field. The following triggers are supported.
 +
 +
* '''On Load''' - System Call is executed by the server when page is requested.
 +
* '''On Demand''' - System Call is executed by the server when the user clicks a button on the page.
 +
** The button will be displayed for the [[Custom Field Type: Special – Browser Script|Browser Script]] field when you select this type of trigger.
 +
** Note that this is the only time the [[Custom Field Type: Special – Browser Script|Browser Script]] field type has any visibility on a page.
 +
** '''On Save''' - System Call is executed by the server when page is saved.
 +
Note that [[Custom Field Type: Special – Browser Script|Browser Script]] fields triggered ''On Load'' or ''On Save'' can only use System Calls, not custom JavaScript, as they are processed server-side.
 +
 +
==System Call Examples==
 
<pre><!--SysCall_updatestatus(@objtype@,@objid@,'StatusName')-->
 
<pre><!--SysCall_updatestatus(@objtype@,@objid@,'StatusName')-->
 +
<!--SysCall_workflow(@objtype@,@objid@,'myworkflow')-->
 +
<!--SysCall_workflow(23,@parent.objid@,'myworkflow')-->
 +
<!--SysCall_workflow(levelone,@parent.objid@,'myworkflow')--></pre>
 +
 +
** @objtype@ and @objid@ are reserved words.
 +
** Objtype can be referenced to the integer value associated with the entity type (23, 18, 30, 40) or constants can be used such as levelone, level1, leveltwo, level2, levelthree, level3, contact, people, company. See [[Entity IDs]] for complete list of entity types.
 +
** Important: Ensure there are no spaces between parameters (i.e. before or after the commas)
 +
'''Note: ''' If, on an ''On Demand'' browser script, you are adding more JavaScript after the System Call, then add a semi-colon at the end of the system call to ensure that there are no script errors.
  
<!--SysCall_workflow(@objtype@,@objid@,'myworkflow')@-->
+
<pre><!--SysCall_workflow(@objtype@,@objid@,'myworkflow')-->;
 +
alert("System call and alert work fine.");
 +
</pre>
  
<!--SysCall_workflow(23,@parent.objid@,'myworkflow')@-->
+
'''On Demand''' system calls pass the button element to the function as parameter '''el'''. This can be used to disable the button or change the value to indicate when the function is complete. For example:
  
<!--SysCall_workflow(levelone,@parent.objid@,'myworkflow')@-->
+
<pre>
 +
<!--SysCall_workflow(@objtype@,@objid@,'Test Web Services')-->;
 +
el.value="Done";
 +
el.disabled=true;
 
</pre>
 
</pre>
<br/>**@objtype@ and @objid@ are reserved words
 
  
<br/>**Objtype can be integer(23,18,30,40) or constants {levelone,level1,leveltwo,level2,levelthree,level3,contact,people,company}
 
  
 +
==Available System Calls==
 +
The following System Calls are currently in production
 +
 +
<pre>SysCall_updatestatus(objecttype,objectid,'StatusName')
 +
 +
Update the status of an object to a new status.</pre>
 +
 +
<pre>SysCall_workflow(objecttype,objectid,'WorkflowTriggerName')
 +
 +
Call a workflow</pre>
 +
 +
<pre>SysCall_activatepeople(userid,activateType)
 +
 +
Activate a contact as a user.  The activateType can be set to:
 +
 +
0 = deactivate existing users
 +
1 = activate user with access through the administrative or portal interface.
 +
3 = activate user with access through Applicant Tracking Interface only.
 +
5 = activate user with access web service login.</pre>
 +
 +
<pre>SysCall_sendpassword(userid)
 +
 +
Sends password to specified user. Works exactly as "Send Password" button.</pre>
 +
 +
<pre>SysCall_updaterole(userid,updatetype,'rolesNamesDelimitedByCommas')
 +
 +
Update user role.  The updatetype can be set to:
 +
 +
1 = Add roles to contact.
 +
2 = Remove all existing roles and add new roles.
 +
3 = Remove listed roles.</pre>
 +
 +
<pre>SysCall_updatesysvar('VariableName','VariableValue')
 +
 +
Update existing System Variable to new value.
 +
 +
Example: You can increment a numeric system variable called Number using an sscalculation:
 +
 +
<!--SysCall_updatesysvar('Number',<!--@sscalculation('@system.Number@'+1)-->)--> </pre>
 +
 +
<pre>SysCall_updateassociation(companyid,userid,'role name',updatetype))
 +
 +
Update contact association.  The updatetype can be set to:
 +
 +
1 = Add association.
 +
2 = Update association.
 +
3 = Remove association.</pre>
 +
 +
<pre>SysCall_charitycheck(companyid)
 +
Runs the SmartSimple GuideStar Charity Check procedure against the designated company.</pre>
 +
Note: Please review the [[GuideStar Charity Check]] page for full information.
 +
==Examples==
 +
To have a button appear on the contact profile that will enable the user and add the '''Organization Contact''' Role:
  
----
+
*
 +
*: [[File:Activate_sys_call.png|link=]]
 +
** ''Note the visibility condition to ensure this button only appears on inactive contact records.''
 +
** ''Also be sure to set as '''Hide for New Record''' since this will not work until the contact record has been saved the first time.''
 +
To have a button appear on the contact profile that will disable the user:
  
<br> Available Calls
+
*
 +
*: [[File:Deactivate_sys_call.png|link=]]
 +
** ''Note the visibility condition to ensure this button only appears on active contacts, AND to prevent users from disabling their own account.''
 +
** ''Also be sure to set as '''Hide for New Record''' since this will not work until the contact record has been saved the first time.''
  
In production
+
==Proposed Additional System Calls==
<br/>1. SysCall_updatestatus(objecttype,objectid,'StatusName')   
+
We welcome suggestions for additional system calls that would reduce the need for scripting, so please email [mailto:support@smartsimple.com SmartSimple Support] or open a support ticket with [[How_the_SmartSimple_Support_Desk_Works|SmartSimple Support]] with the details of the System Call you would like to add. New proposed System Calls will be added to this article as they become available.
<br/>2. SysCall_workflow(objecttype,objectid,'WorkflowTriggerName')
 
  
<br>Proposed
+
[[Category:JavaScript]]
<br/>3. SysCall_activatepelple(userid,activate type) - activateType can be 0(deactivated), 1(activated),3(applicant job application only),5(web service login)
 
<br/>4. SysCall_updaterole(userid,updatetype,'rolesNameDelimitedByComma') -update can be 1(add roles), 2(remove all existing roles and add new roles),3 (remove listed roles)
 

Latest revision as of 13:57, 13 March 2018

System Call Overview

The System Call feature of SmartSimple provides you with the ability to execute pre-defined system functions on the server and in the process avoid the creation of client side scripting. The benefits of System Calls are as follows:

  • Better performance and security as the execution of the code takes place on the server not in the client browser.
  • More stable, as the System Calls are programmed by SmartSimple and optimized for the platform.
  • You don’t need to know JavaScript in order to use the feature.

Using System Calls

When using system calls you add the System Call references to a Browser Script custom field. The syntax for each System Call is as follows:

<!--SysCall_function(@parameter 1@,@parameter 2@,@parameter N@)-->

Note: Multiple System calls can be embedded in the same script field.

Triggering System Calls

The execution of the System Call is controlled by the trigger that you set for the Browser Script field. The following triggers are supported.

  • On Load - System Call is executed by the server when page is requested.
  • On Demand - System Call is executed by the server when the user clicks a button on the page.
    • The button will be displayed for the Browser Script field when you select this type of trigger.
    • Note that this is the only time the Browser Script field type has any visibility on a page.
    • On Save - System Call is executed by the server when page is saved.

Note that Browser Script fields triggered On Load or On Save can only use System Calls, not custom JavaScript, as they are processed server-side.

System Call Examples

<!--SysCall_updatestatus(@objtype@,@objid@,'StatusName')-->
<!--SysCall_workflow(@objtype@,@objid@,'myworkflow')-->
<!--SysCall_workflow(23,@parent.objid@,'myworkflow')-->
<!--SysCall_workflow(levelone,@parent.objid@,'myworkflow')-->
    • @objtype@ and @objid@ are reserved words.
    • Objtype can be referenced to the integer value associated with the entity type (23, 18, 30, 40) or constants can be used such as levelone, level1, leveltwo, level2, levelthree, level3, contact, people, company. See Entity IDs for complete list of entity types.
    • Important: Ensure there are no spaces between parameters (i.e. before or after the commas)

Note: If, on an On Demand browser script, you are adding more JavaScript after the System Call, then add a semi-colon at the end of the system call to ensure that there are no script errors.

<!--SysCall_workflow(@objtype@,@objid@,'myworkflow')-->;
alert("System call and alert work fine.");

On Demand system calls pass the button element to the function as parameter el. This can be used to disable the button or change the value to indicate when the function is complete. For example:

<!--SysCall_workflow(@objtype@,@objid@,'Test Web Services')-->;
el.value="Done";
el.disabled=true;


Available System Calls

The following System Calls are currently in production

SysCall_updatestatus(objecttype,objectid,'StatusName')

Update the status of an object to a new status.
SysCall_workflow(objecttype,objectid,'WorkflowTriggerName')

Call a workflow
SysCall_activatepeople(userid,activateType)

Activate a contact as a user.  The activateType can be set to:

0 = deactivate existing users
1 = activate user with access through the administrative or portal interface.
3 = activate user with access through Applicant Tracking Interface only.
5 = activate user with access web service login.
SysCall_sendpassword(userid)

Sends password to specified user. Works exactly as "Send Password" button.
SysCall_updaterole(userid,updatetype,'rolesNamesDelimitedByCommas')

Update user role.  The updatetype can be set to:

1 = Add roles to contact.
2 = Remove all existing roles and add new roles.
3 = Remove listed roles.
SysCall_updatesysvar('VariableName','VariableValue')

Update existing System Variable to new value.

Example: You can increment a numeric system variable called Number using an sscalculation:

<!--SysCall_updatesysvar('Number',<!--@sscalculation('@system.Number@'+1)-->)--> 
SysCall_updateassociation(companyid,userid,'role name',updatetype))

Update contact association.  The updatetype can be set to:

1 = Add association.
2 = Update association.
3 = Remove association.
SysCall_charitycheck(companyid)
Runs the SmartSimple GuideStar Charity Check procedure against the designated company.
Note: Please review the GuideStar Charity Check page for full information. 

Examples

To have a button appear on the contact profile that will enable the user and add the Organization Contact Role:

  • Activate sys call.png
    • Note the visibility condition to ensure this button only appears on inactive contact records.
    • Also be sure to set as Hide for New Record since this will not work until the contact record has been saved the first time.

To have a button appear on the contact profile that will disable the user:

  • Deactivate sys call.png
    • Note the visibility condition to ensure this button only appears on active contacts, AND to prevent users from disabling their own account.
    • Also be sure to set as Hide for New Record since this will not work until the contact record has been saved the first time.

Proposed Additional System Calls

We welcome suggestions for additional system calls that would reduce the need for scripting, so please email SmartSimple Support or open a support ticket with SmartSimple Support with the details of the System Call you would like to add. New proposed System Calls will be added to this article as they become available.