<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Efficy Overflow Q&amp;A - Recent questions tagged 10sp2</title>
<link>https://overflow.efficy.io/?qa=tag/10sp2</link>
<description>Powered by Question2Answer</description>
<item>
<title>Import html template from file in serverscript</title>
<link>https://overflow.efficy.io/?qa=3856/import-html-template-from-file-in-serverscript</link>
<description>&lt;p&gt;Hi,&lt;/p&gt;

&lt;p&gt;After speak with the Efficy support, I have to use a serverscript to generate html.&lt;br&gt;
This serverscript will be call in a macro with a RunScript.&lt;/p&gt;

&lt;p&gt;I prefer not to put so many html directly in the serverscript, I find that it is not a &quot;good practice&quot; and make the script less readable..&lt;br&gt;
&lt;strong&gt;Is there a way to import html from a page in server script with &lt;em&gt;Efficy 10.2&lt;/em&gt; ?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Example :&lt;br&gt;
&lt;strong&gt;serverscripts/Example.js&lt;/strong&gt;&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;/* function called by &amp;lt;%RunScript(...)%&amp;gt; */
function GetCustomHtmlTable() {
  var EditHandle = Request.ContextHandle,
      HtmlTemplate = &quot;IMPORT HTML FROM HTML FILE ? like pages/grid/HtmlTemplate.htm ?&quot;

  /* some code to get the rights values */
  var name = Database.GetFieldValue(EditHandle, 'NAME'), // in this example : 'My custom header'
      description = 'some text',
      otherData = 'otherData...'

  /* Generate html and return it */
  return ParseTemplate(HtmlTemplate, name, description, otherData);
}

/* this function replace each %s in the template by the others params value in args */
function ParseTemplate(template) {
  var args = [].slice.call(arguments, 1),
      i = 0;

  return template.replace(/%s/g, function() {
      return args[i++];
  });
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;HtmlTemplate.htm&lt;/strong&gt;&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&amp;lt;div class=&quot;CustomClasses&quot;&amp;gt;
  &amp;lt;div class=&quot;header&quot;&amp;gt;%s&amp;lt;/div&amp;gt;
  &amp;lt;div class=&quot;body&quot;&amp;gt;%s&amp;lt;/div&amp;gt;
  &amp;lt;div class=&quot;footer&quot;&amp;gt;%s&amp;lt;/div&amp;gt;
&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;This will return :&lt;/strong&gt;&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&amp;lt;div class=&quot;CustomClasses&quot;&amp;gt;
  &amp;lt;div class=&quot;header&quot;&amp;gt;My custom header&amp;lt;/div&amp;gt;
  &amp;lt;div class=&quot;body&quot;&amp;gt;some text&amp;lt;/div&amp;gt;
  &amp;lt;div class=&quot;footer&quot;&amp;gt;otherData...&amp;lt;/div&amp;gt;
&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
</description>
<category>WorkFlow / Serverscript</category>
<guid isPermaLink="true">https://overflow.efficy.io/?qa=3856/import-html-template-from-file-in-serverscript</guid>
<pubDate>Fri, 11 Jan 2019 22:18:33 +0000</pubDate>
</item>
<item>
<title>Change part of reference after commit on Efficy 10SP2+</title>
<link>https://overflow.efficy.io/?qa=2770/change-part-of-reference-after-commit-on-efficy-10sp2</link>
<description>&lt;p&gt;Hello,&lt;/p&gt;

&lt;p&gt;I'm trying in Efficy 10SP2+ workflow to apply the following function to modify part of a reference after commit, this reference has &quot;cannot modify&quot; checkbox ticked&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;function ModifyReference(EditHandle, Inserted){
    var DS = Database.GetMasterDataSet(EditHandle, 0);
    var reference = DS.FieldByName('REFERENCE').AsString;
    if(reference.indexOf('CI-###-') &amp;gt; -1){
        var d_terminate = DS.FieldByName('F_D_TERMINATION').AsString;
        var newReference= reference.replace('###', d_terminate);
        try{
            Database.DisableSecurity = true;
            Database.DisableWorkflow = true;
            Database.UpdateStringField(EditHandle, 0, &quot;REFERENCE&quot;, newReference);
            Database.CommitChanges(EditHandle, false);          
        } finally{
            Database.DisableWorkflow = PrevWFState;
            Database.DisableSecurity = PrevSecState;
        }       

    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;But i'm always getting the following error, even same functionality used to work on previous versions&lt;br&gt;
&lt;img src=&quot;https://overflow.efficy.com/?qa=blob&amp;amp;qa_blobid=1645982555218765130&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;

&lt;p&gt;If i removed the checkbox tick on reference (so it can be modified), the script runs smoothly. But i;m pretty sure it was working with no problems on previous Efficy releases even with that checkbox ticked.&lt;/p&gt;

&lt;p&gt;Please advise.&lt;br&gt;
Thank you for your help in advance.&lt;br&gt;
Best Regards.&lt;/p&gt;
</description>
<category>WorkFlow / Serverscript</category>
<guid isPermaLink="true">https://overflow.efficy.io/?qa=2770/change-part-of-reference-after-commit-on-efficy-10sp2</guid>
<pubDate>Mon, 27 Nov 2017 14:32:53 +0000</pubDate>
</item>
</channel>
</rss>