User Tools

Site Tools


servicenow_salesforce_content_version

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
servicenow_salesforce_content_version [2019/12/04 15:13]
vinhn [Transform Maps]
servicenow_salesforce_content_version [2020/05/19 11:11]
vinhn
Line 6: Line 6:
 Salesforce content version is another form of attachments. ServiceNow only has attachments and will only send out "​attachments."​ The only configuration needed for Salesforce content version is a transform map so that it can be transformed into an attachment. Salesforce content version is another form of attachments. ServiceNow only has attachments and will only send out "​attachments."​ The only configuration needed for Salesforce content version is a transform map so that it can be transformed into an attachment.
  
-==== Transform Maps ==== +==== Import Set Table ==== 
-Refer to the images ​and scripts below for an example ​on how to configure ​the transform map.+Navigate ​to the search bar at the top left of your ServiceNow window ​and search u_sfdc_content_version_import.list. From here, right click on a column header and go to configure ​> business rules.
  
-{{::​contentversion_transformmap_1.png|}}+Create a new business rule and follow the examples below:
  
-Table Name+{{::​content_version_br_1.png|}} 
-<​code>​ +{{::​content_version_br_2.png|}} 
-return "​incident";​ +{{::​content_version_br_3.png|}}
-</​code>​+
  
-Table Sys Id:+Content version business rule script:
 <​code>​ <​code>​
-var gr = new GlideRecord("​incident"​);​ +(function executeRule(currentprevious /*null when async*/ ​{
-gr.addQuery("​correlation_id"​source.u_linkedentityid)+
-gr.query();​ +
-gr.next();​ +
-return gr.sys_id;​ +
-</​code>​+
  
-Once the field mappings has been createdit is necessary to create the onBefore script to correctly process the content version attachments and insert them+    var gr = new GlideRecord("​incident"​);​ 
- +    gr.addQuery("​correlation_id"​current.u_linkedentityid);​ 
-{{::​contentversion_transformmap_2.png|}} +    ​gr.query();​ 
- +    if (!legal.next()) { 
-<​code>​ +        ignore = true; 
-ignore = true;+        return; 
 +    }
  
-var sysAtt ​ new GlideRecord("​sys_attachment"​); +    ​var attachment ​= new Attachment(); 
-sysAtt.addQuery("content_type", source.u_filetype); +    ​attachment.setTargetTable("incident"); 
-sysAtt.addQuery("​file_name",​ source.u_title);​ +    attachment.setTargetID(gr.sys_id); 
-sysAtt.addQuery("​size_bytes",​ source.u_length); +    ​attachment.setFilename(current.u_title);​ 
-sysAtt.query(); +    ​attachment.setContentType(current.u_fileType); 
-sysAtt.next();+    ​attachment.setValue(new GlideStringUtil().base64DecodeAsBytes(current.u_bodycontent)); 
 +    ​attachment.attach();
  
-var gr = new GlideRecord("​sys_attachment_docs"​);​ +})(current, previous);
-gr.initialize()+
-gr.data = source.u_bodycontent;​ +
-gr.length = source.u_length;​ +
-gr.sys_attachment = sysAtt.sys_id;​ +
-gr.insert();+
 </​code>​ </​code>​
  
servicenow_salesforce_content_version.txt · Last modified: 2020/05/19 11:11 by vinhn