User Tools

Site Tools


siam_sharepoint

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
siam_sharepoint [2018/08/08 15:41]
connie.su [Content from Sharepoint]
siam_sharepoint [2018/08/24 15:07] (current)
timothy.pike [Content from Sharepoint]
Line 185: Line 185:
   - Click on "​OK"​ to save your settings   - Click on "​OK"​ to save your settings
  
-If you want to revert back to the default, you would need to contact ​[[support@perspectium.com|support@perspectium.com]] ​again.+Next, you will need to transform the content from the messages you would receive after importing articles.  
 +  - In ServiceNow, go to **Inbound Maps** under **Sharepoint SIAM** and click on **PSP Common Knowledge**. 
 +  - In the **Field Maps** tableclick **u_text**. 
 +  - Check the **Use source script** checkbox. 
 +  - Follow the instructions for one of the two options described below: 
 + 
 +**Option 1 - URL** 
 + 
 +To have just the URL and the item, copy and paste the following:​ 
 + 
 +<​code>​ 
 +function escapeRegExp(str) { 
 +    return str.replace(/​([.*+?​^=!:​${}()|\[\]\/​\\])/​g,​ "​\\$1"​);​ 
 +
 + 
 +function replaceAll(str,​ find, replace) { 
 +  return str.replace(new RegExp(escapeRegExp(find),​ '​g'​),​ replace); 
 +
 + 
 +function prefixURL(text) {  
 +    var pv = pspUtil.getPspPropertyValue("​com.perspectium.siam.sharepoint.base_url",​ "​unknown"​);​ 
 +  
 + if (pv == "​unknown"​) 
 + return text; 
 +  
 + if(!pv.endsWith("/"​)) 
 + pv = pv + "/";​ // endsure that URL endswith "/"​ 
 +  
 + if (text.indexOf("<​a href=\"/"​) > 0) 
 + text = replaceAll(text,​ "<a href=\"/",​ "<a href=\""​ + pv ); 
 +  
 + if (text.indexOf("​ src=\"/"​) > 0) 
 + text = replaceAll(text,​ " src=\"/",​ " src=\""​ + pv ); 
 +  
 + return text; 
 +
 + 
 +function defaultTransformEntry(source) { 
 + 
 + // if there is no text, insert the origin URL to page 
 + if (!source.u_text.nil()) 
 + return prefixURL(source.u_text.toString());​ // return the value to be put into the target field 
 +  
 + var olink = "<​p><​a title='"​ + source.u_origin + "'​ href='"​ + source.u_origin + "'​ target='​_blank'>"​ + source.u_origin + "</​a></​p>";​ 
 + return olink; 
 +
 + 
 +answer = defaultTransformEntry(source);​ 
 +</​code>​ 
 + 
 + 
 +**Option 2 - Actual Content** 
 + 
 +To have the item's actual content, copy and paste the following (Make sure you have changed your mapping with [[support@perspectium.com|support]]):​ 
 + 
 +<​code>​ 
 +function escapeRegExp(str) { 
 +    return str.replace(/​([.*+?​^=!:​${}()|\[\]\/​\\])/​g,​ "​\\$1"​);​ 
 +
 + 
 +function replaceAll(str,​ find, replace) { 
 +  return str.replace(new RegExp(escapeRegExp(find),​ '​g'​),​ replace); 
 +
 + 
 +function prefixURL(text) {  
 +    var pv = pspUtil.getPspPropertyValue("​com.perspectium.siam.sharepoint.base_url",​ "​unknown"​);​ 
 +  
 + if (pv == "​unknown"​) 
 + return text; 
 +  
 + if(!pv.endsWith("/"​)) 
 + pv = pv + "/";​ // endsure that URL endswith "/"​ 
 +  
 + if (text.indexOf("<​a href=\"/"​) > 0) 
 + text = replaceAll(text,​ "<a href=\"/",​ "<a href=\""​ + pv ); 
 +  
 + if (text.indexOf("​ src=\"/"​) > 0) 
 + text = replaceAll(text,​ " src=\"/",​ " src=\""​ + pv ); 
 +  
 + return text; 
 +
 + 
 +function defaultTransformEntry(source) { 
 + 
 + // if there is no text, insert the origin URL to page 
 + if (!source.u_text.nil()) 
 + return prefixURL(source.u_text.toString());​ // return the value to be put into the target field 
 +  
 + var olink = "<​p><​a title='"​ + source.u_origin + "'​ href='"​ + source.u_origin + "'​ target='​_blank'>"​ + source.u_origin + "</​a></​p>";​ 
 + return olink; 
 +
 + 
 +answer = (function contentTransformEntry(source) { 
 + if (source.u_origin.indexOf('​DispForm.aspx?​ID'​) == -1 || source.u_text.nil()) { 
 + return defaultTransformEntry(source);​ 
 +
 +  
 + var text = source.u_text.toString();​ 
 + var formatContent = text.split(/<​p><​\/​p>​|<​p>​nbsp;<​\/​p>/​);​ 
 + var content = "";​ 
 +  
 + // removes empty strings 
 + formatContent = formatContent.filter(Boolean);​ 
 +  
 + for (var i = 0; i < formatContent.length;​ i++) { 
 + content += formatContent[i];​ 
 +
 +  
 + return content; 
 +})(source);</​code>​ 
 + 
 +To revert back to your default settings, e-mail **[[support@perspectium.com|support@perspectium.com]]** to change your Field Map and use the URL.
siam_sharepoint.1533768072.txt.gz · Last modified: 2018/08/08 15:41 by connie.su