User Tools

Site Tools


before_share_script

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
before_share_script [2015/09/22 15:35]
paul
before_share_script [2018/05/15 00:13] (current)
paul [psp_key]
Line 20: Line 20:
 Note if you have multiple share configurations for the same table (such as different share configurations that each have a different target queue), any changes to the current object may affect any conditions you have to share since this same current object is referenced as we iterate through the table'​s different share configurations. Note if you have multiple share configurations for the same table (such as different share configurations that each have a different target queue), any changes to the current object may affect any conditions you have to share since this same current object is referenced as we iterate through the table'​s different share configurations.
  
-For example, if your have multiple share conditions for the ticket table (one will share to the target queue psp.out.servicenow.test and the other shares to the queue psp.out.servicenow.dev) and all have the condition short_description is '​test'​ in order to share records, if one of your share configurations has the before share script of:+For example, if you have multiple share conditions for the ticket table (one will share to the target queue psp.out.servicenow.test and the other shares to the queue psp.out.servicenow.dev) and all have the condition short_description is '​test'​ in order to share records, if one of your share configurations has the before share script of:
 current.short_description = '​test123'​ current.short_description = '​test123'​
  
 Then other share configurations for this will not share the record to their target queues since the short_description of the current object has been changed to '​test123'​. Then other share configurations for this will not share the record to their target queues since the short_description of the current object has been changed to '​test123'​.
 </​WRAP>​ </​WRAP>​
 +
 +===== Ignore or Cancel Share =====
 +{{page>​ignoring_share_in_before_share_script&​noheader&​nofooter}}
 +
 +===== psp_action =====
 +{{page>​psp_action_in_before_share_script&​noheader&​nofooter}}
 +
 +===== share_gr =====
 +<wrap info>​v3.31.0</​wrap>​\\
 +To access the Bulk and Dynamic Share records themselves from the Before Share Script, use the global variable //​share_gr//​. ​
 +
 +For example, the following Before Share script will log the value of the current Bulk/​Dynamic share record'​s system id:
 +
 +<code javascript>​
 +gs.log(share_gr.sys_id);​
 +</​code>​
 +
 +===== previous =====
 +<wrap info>​v3.31.0</​wrap>​\\
 +To access the previous record in a Dynamic Share (ie, a record before it has been modified), use the global variable //​previous//​ in the Before Share script. ​ For example, the following script will log the value of the previous record’s short description:​
 +
 +<code javascript>​
 +gs.log(previous.short_description);​
 +</​code>​
 +
 +As another example, you can compare the field values of the previous and current records being shared dynamically. ​
 +
 +<code javascript>​
 +if(current.short_description != previous.short_description){
 + //do something here
 +}
 +</​code>​
 +
 +<WRAP round important>​
 +*Note: you can only access the //​previous//​ variable when the “Business Rule When” is set to “before” or “after” under Trigger Conditions of the Dynamic Share (it will not work with “async”).
 +
 +In addition, the information above only applies to Dynamic Shares; the data shared in a Bulk Share is historical and will not have been modified.
 +</​WRAP>​
 +===== psp_key =====
 +<wrap info>​[[carbon_release|Carbon]]</​wrap>​\\
 +To access the key value of the outbound message, you can change the psp_key global dynamically.
 +
 +To enabled this functionality,​ turn off com.perspectium.validate_mismatch_key in your Perspectium properties.
 +
 +<code javascript>​
 +// run on before share
 +psp_key = "​custom_client";​
 +</​code>​
before_share_script.1442961338.txt.gz · Last modified: 2015/09/22 15:35 by paul