<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Efficy Overflow Q&amp;A - Recent questions tagged serverjs</title>
<link>https://overflow.efficy.io/?qa=tag/serverjs</link>
<description>Powered by Question2Answer</description>
<item>
<title>Syntax for function OnAddLinkOppoPubl(Key, DetailKey)</title>
<link>https://overflow.efficy.io/?qa=7172/syntax-for-function-onaddlinkoppopubl-key-detailkey</link>
<description>&lt;p&gt;Hi,&lt;br&gt;
What is the syntax using the function OnAddLinkOppoPubl(Key, DetailKey) ?&lt;br&gt;
I just want to update the STATUS field of the opportunity after adding a link from the publication to the opportunity.&lt;br&gt;
Thank you&lt;br&gt;
Dimitri&lt;/p&gt;
</description>
<category>WorkFlow / Serverscript</category>
<guid isPermaLink="true">https://overflow.efficy.io/?qa=7172/syntax-for-function-onaddlinkoppopubl-key-detailkey</guid>
<pubDate>Tue, 22 Apr 2025 10:17:09 +0000</pubDate>
</item>
<item>
<title>Get regional settings in serverJS</title>
<link>https://overflow.efficy.io/?qa=6816/get-regional-settings-in-serverjs</link>
<description>&lt;p&gt;Is it possible to get usersettings by a serverJS function?&lt;/p&gt;

&lt;p&gt;This is an working example:&lt;br&gt;
var maxUsedDays = Efficy.getSetting('User', 'MaxUsedDays');&lt;/p&gt;

&lt;p&gt;This is what I am looking for  and currently not working:&lt;br&gt;
Efficy.getSetting('User', 'DecimalPoint')&lt;br&gt;
Efficy.getSetting('User', 'decimalPoint')&lt;br&gt;
Efficy.getSetting('User', 'ShortDateFormat')&lt;br&gt;
I also tried:&lt;br&gt;
Efficy.getSetting('Efficy.User', '') &lt;br&gt;
etc.&lt;/p&gt;

&lt;p&gt;Questions:&lt;br&gt;
Is it possible to get this working?&lt;br&gt;
Is there a list of working examples?&lt;br&gt;
Or an other way to get user regional settings?&lt;/p&gt;
</description>
<category>Efficy/ Client side</category>
<guid isPermaLink="true">https://overflow.efficy.io/?qa=6816/get-regional-settings-in-serverjs</guid>
<pubDate>Fri, 17 Feb 2023 11:47:47 +0000</pubDate>
</item>
<item>
<title>How translate message / label into a standard serverJS like spyCases.js</title>
<link>https://overflow.efficy.io/?qa=6604/translate-message-label-into-standard-serverjs-like-spycases</link>
<description>&lt;p&gt;We need to customize the Spycase file with lot of translations  into the declared var MAILS.&lt;/p&gt;

&lt;p&gt;Depending on USER language preferences we want to translate in some language all the value.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;var MAILS = {
Close  : &quot;The case has been closed by the SpyCase.&quot;,
Remind : &quot;The Customer/Partner has not replied in $0 days.\nPlease send a reminder or tentatively close the case.&quot;,
Revive : &quot;This case has not changed in $0 days.\nThe ticket was waiting for $1.\nPlease take action to activate this case.&quot;,
Links  : &quot;\n___________________________________\nThis case is linked to $0$1$2&quot;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;So we basically searched into the standard to find all those labels into the EfficyLabels txt file and adding our own definitions. But without any success.&lt;br&gt;
So we try to compare with native serverJS where some labels are translated.&lt;br&gt;
So we found some translation into few serverJS like invoicing/invoicing.js with &lt;/p&gt;

&lt;pre&gt;&lt;code&gt;if (!mainLinkedEntityId) throw new Error(format(Utils.translate('The main linked $0 could not be retrieved'), linkedEntity)); 
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;or into workload/roadmapElement.js&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;if (!this.hasRight(right, projKey, nodeType, nodeKey, fields)) {
throw new Error(
format(
Request.translate('You need the $0 right on the $1 #$2 to perform this action'),
right,
Efficy.entityCatalog.getEntityName(ntTable),
nodeKey
)
);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;We tried to add needed modules to run a translation but nothing worked.&lt;br&gt;
So anybody has already translated this kind of labels into a serverJS used into the Scheduled Efficy Service ?&lt;/p&gt;

&lt;p&gt;Thank's&lt;br&gt;
Laurent Tuffraud &lt;/p&gt;
</description>
<category>WorkFlow / Serverscript</category>
<guid isPermaLink="true">https://overflow.efficy.io/?qa=6604/translate-message-label-into-standard-serverjs-like-spycases</guid>
<pubDate>Thu, 16 Jun 2022 09:23:06 +0000</pubDate>
</item>
<item>
<title>How to reset user (using SetUsers true) except resources.</title>
<link>https://overflow.efficy.io/?qa=6356/how-to-reset-user-using-setusers-true-except-resources</link>
<description>&lt;p&gt;I want to reset users into the workflow but I need to keep all users like resources.&lt;br&gt;
Is there a quick way to do that with an Efficy function ?&lt;/p&gt;

&lt;p&gt;My only alternative way is to check user before reset, identify the ressources and add them into my varArrayOf users I want to set.&lt;/p&gt;
</description>
<category>WorkFlow / Serverscript</category>
<guid isPermaLink="true">https://overflow.efficy.io/?qa=6356/how-to-reset-user-using-setusers-true-except-resources</guid>
<pubDate>Tue, 16 Nov 2021 13:02:32 +0000</pubDate>
</item>
<item>
<title>Efficy.sendExternalEmail creates wrong URL - where can we correct the behaviour?</title>
<link>https://overflow.efficy.io/?qa=5832/efficy-sendexternalemail-creates-wrong-correct-behaviour</link>
<description>&lt;p&gt;Hi all,&lt;/p&gt;

&lt;p&gt;if we you the built in &lt;/p&gt;

&lt;pre&gt;&lt;code&gt;Efficy.sendExternalMail(sendFrom, sendTo, sendCc, subject, body, entity, idLinked, sendCode) 
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;function and set the parameter sendCode = 'S' &lt;br&gt;
The added URL to the mail follow the Efficy 10 schema:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;https://mydomain.here/efficy.dll/dialog?page=remote/DialogOperation.htm&amp;amp;action=view;Cont;99958&amp;amp;close=T
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;instead it should look like: &lt;/p&gt;

&lt;pre&gt;&lt;code&gt;https://mydomain.here/crm/view/Cont/99958
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Where can we change this behavior?&lt;/p&gt;

&lt;p&gt;Thank you &lt;/p&gt;

&lt;p&gt;Tim&lt;/p&gt;
</description>
<category>WorkFlow / Serverscript</category>
<guid isPermaLink="true">https://overflow.efficy.io/?qa=5832/efficy-sendexternalemail-creates-wrong-correct-behaviour</guid>
<pubDate>Wed, 27 Jan 2021 11:11:08 +0000</pubDate>
</item>
<item>
<title>Loadserverjs can not be used in the &quot;module&quot; way</title>
<link>https://overflow.efficy.io/?qa=5375/loadserverjs-can-not-be-used-in-the-module-way</link>
<description>&lt;p&gt;Hi all,&lt;/p&gt;

&lt;p&gt;I am doing an upgrade for a customer and i am moving the serverscript files to serverjs.&lt;br&gt;
I made a serverjs file with an object &quot;module&quot; and i am using it to make my api calls.&lt;br&gt;
Now i want to use one of the functions inside my object with a loadserverjs/runscript but this is not working (what is logic), is there a solution for this or do i need to create a new file with the same function without using an object (copy/paste way)?&lt;/p&gt;

&lt;p&gt;Thanks in advance!&lt;/p&gt;

&lt;p&gt;Kind regards,&lt;br&gt;
Bart&lt;/p&gt;
</description>
<category>Efficy/ Client side</category>
<guid isPermaLink="true">https://overflow.efficy.io/?qa=5375/loadserverjs-can-not-be-used-in-the-module-way</guid>
<pubDate>Wed, 25 Mar 2020 15:18:52 +0000</pubDate>
</item>
<item>
<title>What is the key value for SYNCHRO_RELATION_CONTACT in constant.js for flexmail.</title>
<link>https://overflow.efficy.io/?qa=5262/what-the-value-synchrorelationcontact-constant-flexmail</link>
<description>&lt;p&gt;I have to change the way to synchronize flexmail to a new entity. I manipulated the constant.js file into the serverJs and I want to understand  what are the variable values.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt; var SYNCHRO_RELATION_CONTACT = 2,
SYNCHRO_RELATION_PREFERENCE = 24,
TABLEID_CONTACTS = 11000,
TABLEID_PROFILES = 24000,
LK_PROF_FLEXKIND_PREFERENCE = '2',
SYNC_D_CHANGE_ERROR = 10 / 86400,
APPID_SYNCSERVER = 27,
TIMEZONE_UTC = 100,
TIMEZONE_ROMANCE = 172, //172 = GMT+1
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;I don't know what are :&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;SYNCHRO&lt;em&gt;RELATION&lt;/em&gt;CONTACT. (Maybe the USERKEY of ADMIN ?)&lt;/li&gt;
&lt;li&gt;SYNCHRO&lt;em&gt;RELATION&lt;/em&gt;PREFERENCE (24 seem to be relative to the profile table number ?)&lt;/li&gt;
&lt;li&gt;APPID_SYNCSERVER ?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The other variable are clear.&lt;/p&gt;

&lt;p&gt;so can I do something like that and if 2 is the key of administrator user maybe having a customized SYNCHRO&lt;em&gt;RELATION&lt;/em&gt;FONCTION variable is not useful.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;var SYNCHRO_RELATION_CONTACT = 2,
SYNCHRO_RELATION_FONCTION = ??? KEY,
SYNCHRO_RELATION_PREFERENCE = 24,
TABLEID_CONTACTS = 11000,
TABLEID_FONCTIONS = 51000,
TABLEID_PROFILES = 24000,
LK_PROF_FLEXKIND_PREFERENCE = '2',
SYNC_D_CHANGE_ERROR = 10 / 86400,
APPID_SYNCSERVER = 27,
TIMEZONE_UTC = 100,
TIMEZONE_ROMANCE = 172, //172 = GMT+1
&lt;/code&gt;&lt;/pre&gt;
</description>
<category>How to</category>
<guid isPermaLink="true">https://overflow.efficy.io/?qa=5262/what-the-value-synchrorelationcontact-constant-flexmail</guid>
<pubDate>Mon, 27 Jan 2020 17:16:25 +0000</pubDate>
</item>
<item>
<title>Implementing a UserOption feature through sys_storage and serverside scripts</title>
<link>https://overflow.efficy.io/?qa=5224/implementing-useroption-feature-sysstorage-serverside</link>
<description>&lt;p&gt;Hi guys, &lt;/p&gt;

&lt;p&gt;I recently needed to implement a session persistent user options feature in Efficy &lt;br&gt;
since sys_storage is the recommended way to do so I ve made a module that will allow you to set and get user options from a serverjs module.&lt;/p&gt;

&lt;p&gt;this is how to implement / use it : &lt;/p&gt;

&lt;pre&gt;&lt;code&gt;/*
@import SUO from serverjs/storageUserOptions
*/

SUO.init({id: 123});      // optional: only if you  want to use options of another User (default is Efficy.currentUserId)

// for now there is no sys_storage named userOption_123 (yet)

var temp = SUO.get()    
// expected temp = &quot;&quot;;

SUO.set(&quot;myOption&quot;, 12);
// there is now a sys_storage named userOption_123 whose value is : &quot;{\&quot;myOption\&quot;: 12}&quot;    //---(string)

temp = SUO.get();
// expected temp = {&quot;myOption: 12&quot;}   //---(object)  

temp = SUO.get(&quot;myOption&quot;);
// expected temp = 12       //---(number)

SUO.set(&quot;myOption2&quot;, {
    mySubOption1: true,
    mySubOption2: &quot;subOptionValue2&quot;,
    mySubOption3: {
        id: 1
    }
});
// there is now a sys_storage named userOption_123 whose value is : (string)
// {
//     &quot;myOption&quot;: 12,
//     &quot;myOption2&quot;: {
//         &quot;mySubOption1&quot;: true,
//         &quot;mySubOption2&quot;: &quot;subOptionValue2&quot;,
//         &quot;mySubOption3&quot;: {
//             &quot;id&quot;: 1
//         }
//     }
// }
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;this is the code of the serverjs/storageUserOptions module : &lt;/p&gt;

&lt;pre&gt;&lt;code&gt;/*
@import $ from serverjs/jUtils
*/
return (function(){
    var options = {
        id: Efficy.currentUserId
    };

    function test(_options){
        return &quot;test&quot;
    }

    function init(_options){
        if (typeof _options === &quot;object&quot;){
            $.forEach($.keys(_options), function(_key){
                if (options.hasOwnProperty(_key)) options[_key] = _options[_key];
            });
        }

        return options;
    }

    function get(_optionName){
        var result;
        var data = _getStorageUserOptions();

        if (typeof _optionName === &quot;string&quot;) result = data[_optionName];
        else result = data;

        return result;
    }

    function set(_optionName, _optionValue){
        if(typeof _optionName !== &quot;string&quot;) throw new Error(&quot;storageUserOptions.set() invalid arguments&quot;);

        var data = {};
        data[_optionName] = _optionValue;

        _setStorageUserOptions(data);

        return;
    }

    function _setStorageUserOptions(_options){

        var result = _getStorageUserOptions();
        result = $.merge(result, _options);

        Efficy.setSysStorageValue(&quot;userOption_&quot; + options.id, JSON.stringify(result, null, &quot;\t&quot;));

        return result;
    }

    function _getStorageUserOptions(){
        var result = Efficy.getSysStorageValue(&quot;userOption_&quot; + options.id) || &quot;{}&quot;;

        try{
            result = JSON.parse(result);
        } catch(e){
            throw new Error([&quot;&quot;,
                &quot;_getStorageUserOption parse error&quot;, 
                &quot;id: &quot; + options.id,
                &quot;value: &quot; + result,
                &quot;message: &quot; + e.message
            ].join(&quot;&amp;lt;br/&amp;gt;&quot;));
        }

        return result;
    }

    var public = {
        test: test,
        init: init,
        set: set,
        get: get

    };

    return public;
})();
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;and the serverjs/jUtils module that allow me to add some intresting polyfill (like object.keys, merge, ...) &lt;/p&gt;

&lt;pre&gt;&lt;code&gt;return (function(){

    function forEach(_array, _iterator){
        var result;

        for (var i=0; i&amp;lt;_array.length; i++){
            result = _iterator.call(this, _array[i], i);
            if (result === false) break;
        }

        return result;
    }

    function each(_array, _iterator){
        var result;

        for (var i=0; i&amp;lt;_array.length; i++){
            result = _iterator.call(this, i, _array[i]);
            if (result === false) break;
        }
    }

    function merge(){
        var result = {};

        each(arguments, function(_index, _value){
            for(key in _value){
                if (!result[key]){
                    result[key] = _value[key];
                } else if (typeof result[key] === &quot;object&quot; &amp;amp;&amp;amp; typeof result[key].length === &quot;undefined&quot;) {
                    result[key] = merge(result[key], _value[key]);
                } else {
                    result[key] = _value[key];
                }
            }
        });

        return result;  
    }

    function getItem(_array, _searchFunction, _startIndex){
        _startIndex = _startIndex || 0;

        var result = undefined;

        forEach(_array, function(_value, _index){
            if (_searchFunction(_value, _index)){
                result = _value;
                return false;
            }
        });

        return result;
    }

    function format() {
        var args = arguments;
        var result = args[0].replace(/\$\d+/g, function (cap) {
            return args[1 + parseInt(cap.match(/\d+/), 10)];
        });
    }

    function indexOfObject(_array, _searchFunction){

        for (var i=0; i&amp;lt;_array.length; i++){
            if (_searchFunction(_array[i])) {
                return i;
            }
        }

        return -1;
    }

    function getFunctionName(_function){
        var result = _function.toString();
        result = result.substr('function '.length);
        result = result.substr(0, result.indexOf('('));
        return result;
    }

    var keys = (function() {
        'use strict';
        var hasOwnProperty = Object.prototype.hasOwnProperty,
          hasDontEnumBug = !({ toString: null }).propertyIsEnumerable('toString'),
          dontEnums = [
            'toString',
            'toLocaleString',
            'valueOf',
            'hasOwnProperty',
            'isPrototypeOf',
            'propertyIsEnumerable',
            'constructor'
          ],
          dontEnumsLength = dontEnums.length;

        return function(obj) {
          if (typeof obj !== 'function' &amp;amp;&amp;amp; (typeof obj !== 'object' || obj === null)) {
            throw new TypeError('Object.keys called on non-object');
          }

          var result = [], prop, i;

          for (prop in obj) {
            if (hasOwnProperty.call(obj, prop)) {
              result.push(prop);
            }
          }

          if (hasDontEnumBug) {
            for (i = 0; i &amp;lt; dontEnumsLength; i++) {
              if (hasOwnProperty.call(obj, dontEnums[i])) {
                result.push(dontEnums[i]);
              }
            }
          }
          return result;
        };
      }());

    var public = {
        merge: merge,
        forEach: forEach,
        each: each,
        getItem: getItem,
        format: format,
        indexOfObject: indexOfObject,
        getFunctionName: getFunctionName,
        keys: keys
    };

    return public;
})();
&lt;/code&gt;&lt;/pre&gt;
</description>
<category>WorkFlow / Serverscript</category>
<guid isPermaLink="true">https://overflow.efficy.io/?qa=5224/implementing-useroption-feature-sysstorage-serverside</guid>
<pubDate>Tue, 21 Jan 2020 15:46:34 +0000</pubDate>
</item>
<item>
<title>sharing: serverside module to set json data in db (encapsulate the EfficyAPI calls)</title>
<link>https://overflow.efficy.io/?qa=5062/sharing-serverside-module-json-encapsulate-efficyapi-calls</link>
<description>&lt;p&gt;Hi developpers community, &lt;/p&gt;

&lt;p&gt;this is a serverside module I use to set json data in DB quickly in serverside js that encapsulate all the EfficyAPI calls.&lt;/p&gt;

&lt;p&gt;so basically i want to add a company in db i just have something like this to code : &lt;/p&gt;

&lt;pre&gt;&lt;code&gt;rec.set({
    k_company: 0,
    name: &quot;ma société&quot;,
    kind: 3,
    memo: &quot;company created by a cool js module&quot;
})
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;this is a more complete example of what you can set&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;var inserted = rec.set({
    k_company: 0,
    name: &quot;my company&quot;,
    kind: 3,
    memo: &quot;company created by a cool js module&quot;
});

// inserted == 3001

var arrayInserted = rec.set([
    {
        k_company: inserted,
        memo: &quot;updated memo&quot;
    }, {
        k_company: 0,
        name: &quot;my second company&quot;,
        f_custom_field: &quot;valuecustom&quot;
    }
]);

// arrayInserted == [3001, 3002]
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;declaring the module&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;//@import rec from finopsys/recordMgr
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;initializing the module (setting the entity you want to set)&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;rec.init({
     entity: ntComp
});
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;note that you can import several instances of this module if you don't want to reinitialize the module on each call (in case of you have serverals record kinds to set for each line)&lt;/p&gt;

&lt;p&gt;you can also add special properties to the record parameter &lt;/p&gt;

&lt;pre&gt;&lt;code&gt;var inserted = rec.set({
    k_company: 0,
    name: &quot;my company&quot;,
    kind: 3,
    memo: &quot;company created by a cool js module&quot;,
    s_usersecurity: [{k_user: 1, security: 3}],
    s_detail2: [{entity: ntCont, key: 365}]
});
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;s&lt;em&gt;usersecurity: [{k&lt;/em&gt;user: 1, security: 3}]&lt;br&gt;
add the security level 3 to the user 1 to this record (setUserSecurity)&lt;/p&gt;

&lt;p&gt;s_detail2: [{entity: ntCont, key: 365}]&lt;br&gt;
add a link to the contact with key 365 (insert detail2)&lt;/p&gt;

&lt;p&gt;this is the code of the module : recordMgr.js&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;//@import $ from finopsys/jUtils

return (function(){
var options = {
entity: ntComp,
keyfield: &quot;k_company&quot;
};

function test(){
return &quot;returned from custom server module&quot;;
}

function init(_options){
if (typeof _options === &quot;object&quot;){
$.forEach(Object.keys(_options), function(_key){
if (options.hasOwnProperty(_key)) options[_key] = _options[_key];
});
}

options.keyfield = Efficy.sqlQueryValue([
&quot;select &quot;,
&quot;    LOWER(F.NAME)&quot;,
&quot;from&quot;,
&quot;    &amp;lt;#TABLE NAME=SYS_FIELDS&amp;gt; F&quot;,
&quot;    inner join &amp;lt;#TABLE NAME=SYS_TABLES&amp;gt; T on T.K_TABLE = F.K_TABLE&quot;,
&quot;    inner join &amp;lt;#TABLE NAME=SYS_ENTITIES&amp;gt; E on E.K_TABLE = T.K_TABLE&quot;,
&quot;where&quot;,
&quot;    F.USAGE = 'K'&quot;,
&quot;    and E.K_ENTITY = :param1&quot;
].join(&quot;\n&quot;), options.entity, &quot;&quot;);

return options;
}

function set(_data){
var result;

if (typeof _data !== &quot;object&quot;) throw new Error(&quot;the records to set are not in an array&quot;);
if (_data.hasOwnProperty(&quot;length&quot;)){
result = setRecords(_data);
} else {
result = setRecord(_data);
}

return result;
}

function setRecord(_record){

if (typeof _record !== &quot;object&quot;) throw new Error(&quot;the record to set is not an object&quot;);
if (!_record.hasOwnProperty(options.keyfield)) throw new Error(&quot;the record to set has no keyfield property&quot;);

var key = _record[options.keyfield];

var editHandle = Efficy.openEditContext(options.entity, _record[options.keyfield], false);
try {
var ds = Efficy.getMasterDataSet(editHandle, 0);
ds.edit();

$.forEach(Object.keys(_record), function(_key){
if (_key === options.keyfield){
key = ds.fieldByName(_key).value;
} else if (ds.findField(_key)) {
if(typeof _record[_key] === &quot;string&quot;) ds.fieldByName(_key).asString = _record[_key];
else ds.fieldByName(_key).value = _record[_key];
}
});

if (_record[&quot;s_usersecurity&quot;]){
$.forEach(_record[&quot;s_usersecurity&quot;], function(_usersecurity){
Efficy.setUserSecurity(editHandle, _usersecurity.k_user, _usersecurity.security);
});
}

if (_record[&quot;s_detail2&quot;]){
$.forEach(_record[&quot;s_detail2&quot;], function(_detail2){
Efficy.insertDetail2(editHandle, _detail2.entity, _detail2.key, false);
});
}

Efficy.commitChanges(editHandle, false);            
} finally {
Efficy.closeContext(editHandle);
}

return key;
}

function setRecords(_records){
var result = new Array();

$.forEach(_records, function(_record){
result.push(setRecord(_record));
});

return result;
}

var public = {
test: test,
init: init,
set: set
};

return public;
})();
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;and this is the code of jUtils.js a module I ve done to help the serverside script with some usefull functions &lt;/p&gt;

&lt;pre&gt;&lt;code&gt;return (function(){

function forEach(_array, _iterator){
var result;

for (var i=0; i&amp;lt;_array.length; i++){
result = _iterator.call(this, _array[i], i);
if (result === false) break;
}

return result;
}

function each(_array, _iterator){
var result;

for (var i=0; i&amp;lt;_array.length; i++){
result = _iterator.call(this, i, _array[i]);
if (result === false) break;
}
}

function merge(){
var result = {};

each(arguments, function(_index, _value){
for(key in _value){
if (!result[key]){
result[key] = _value[key];
} else if (typeof result[key] === &quot;object&quot; &amp;amp;&amp;amp; typeof result[key].length === &quot;undefined&quot;) {
result[key] = merge(result[key], _value[key]);
} else {
result[key] = _value[key];
}
}
});

return result;  
}

function getItem(_array, _searchFunction, _startIndex){
_startIndex = _startIndex || 0;

var result = undefined;

forEach(_array, function(_value, _index){
if (_searchFunction(_value, _index)){
result = _value;
return false;
}
});

return result;
}

function format() {
var args = arguments;
var result = args[0].replace(/\$\d+/g, function (cap) {
return args[1 + parseInt(cap.match(/\d+/), 10)];
});
}

function indexOfObject(_array, _searchFunction){

for (var i=0; i&amp;lt;_array.length; i++){
if (_searchFunction(_array[i])) {
return i;
}
}

return -1;
}

function getFunctionName(_function){
var result = _function.toString();
result = result.substr('function '.length);
result = result.substr(0, result.indexOf('('));
return result;
}

var public = {
merge: merge,
forEach: forEach,
each: each,
getItem: getItem,
format: format,
indexOfObject: indexOfObject,
getFunctionName: getFunctionName
};

return public;
})();
&lt;/code&gt;&lt;/pre&gt;
</description>
<category>WorkFlow / Serverscript</category>
<guid isPermaLink="true">https://overflow.efficy.io/?qa=5062/sharing-serverside-module-json-encapsulate-efficyapi-calls</guid>
<pubDate>Thu, 21 Nov 2019 13:48:55 +0000</pubDate>
</item>
<item>
<title>EditNewWithScript2 with server js</title>
<link>https://overflow.efficy.io/?qa=4966/editnewwithscript2-with-server-js</link>
<description>&lt;p&gt;Hi all,&lt;/p&gt;

&lt;p&gt;I needed to created a button which duplicate an opportunity whitout his details.&lt;br&gt;
To do this i used the following code: &lt;code&gt;EditNewWithScript2('Oppo', extraParams, '../serverjs/entities/oppo', 'duplicateOppo');&lt;/code&gt; &lt;/p&gt;

&lt;p&gt;It is possible to call a serverjs but in the &quot;serverscript&quot; way. Is it possible to call a real serverjs (with module and privates) via this code snippet?&lt;/p&gt;

&lt;p&gt;Thanks in advance!&lt;/p&gt;
</description>
<category>Efficy/ Client side</category>
<guid isPermaLink="true">https://overflow.efficy.io/?qa=4966/editnewwithscript2-with-server-js</guid>
<pubDate>Mon, 28 Oct 2019 15:16:30 +0000</pubDate>
</item>
<item>
<title>Could we create companies reference using Efficy designer?</title>
<link>https://overflow.efficy.io/?qa=4849/could-we-create-companies-reference-using-efficy-designer</link>
<description>&lt;p&gt;Hello,&lt;/p&gt;

&lt;p&gt;I want to create a reference for companies, could we use the designer or we should do it using a database workflow?&lt;/p&gt;

&lt;p&gt;Thank you&lt;/p&gt;

&lt;p&gt;Regards&lt;/p&gt;
</description>
<category>Efficy Designer (Conficy)</category>
<guid isPermaLink="true">https://overflow.efficy.io/?qa=4849/could-we-create-companies-reference-using-efficy-designer</guid>
<pubDate>Thu, 03 Oct 2019 10:23:57 +0000</pubDate>
</item>
<item>
<title>How to customise a &quot;private method&quot; in a standard serverJS file</title>
<link>https://overflow.efficy.io/?qa=4789/how-to-customise-a-private-method-in-standard-serverjs-file</link>
<description>&lt;p&gt;Hello Efficy Team, &lt;/p&gt;

&lt;p&gt;This question is related to the answer of Kristof.&lt;br&gt;
We would like to customise the method &quot;importTimesheetFromDataSet&quot;, but we cannot access the method.&lt;/p&gt;

&lt;p&gt;How could we do that ? &lt;/p&gt;

&lt;p&gt;Regards, &lt;/p&gt;

&lt;p&gt;Loïc&lt;/p&gt;
</description>
<category>WorkFlow / Serverscript</category>
<guid isPermaLink="true">https://overflow.efficy.io/?qa=4789/how-to-customise-a-private-method-in-standard-serverjs-file</guid>
<pubDate>Fri, 13 Sep 2019 12:42:13 +0000</pubDate>
</item>
<item>
<title>How to customize something in a module of a serverJS</title>
<link>https://overflow.efficy.io/?qa=4783/how-to-customize-something-in-a-module-of-a-serverjs</link>
<description>&lt;p&gt;Hello Efficy team, &lt;/p&gt;

&lt;p&gt;I need to customize the method &quot;importToTimesheet&quot; from serverJS/workload/timesheet&quot;.&lt;br&gt;
This method is part of literal object &quot;module&quot;.&lt;/p&gt;

&lt;p&gt;How could I do that without coping the all file ?&lt;/p&gt;

&lt;p&gt;We tried this (in a timesheet.js file, in the custom) : &lt;/p&gt;

&lt;pre&gt;&lt;code&gt;/*
@import Timesheet from &quot;workload/timesheet&quot;;
*/

Timesheet.importToTimesheet = function() {
throw new Error('Hello ?');
}

return Timesheet;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;But we get this error (when the page load) : &lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://overflow.efficy.com/?qa=blob&amp;amp;qa_blobid=2622706383534129016&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;

&lt;p&gt;What is the &lt;strong&gt;best practice&lt;/strong&gt; ? Coping the all file make no sens.&lt;/p&gt;

&lt;p&gt;Regards, &lt;/p&gt;

&lt;p&gt;Loïc&lt;/p&gt;
</description>
<category>WorkFlow / Serverscript</category>
<guid isPermaLink="true">https://overflow.efficy.io/?qa=4783/how-to-customize-something-in-a-module-of-a-serverjs</guid>
<pubDate>Fri, 13 Sep 2019 10:27:06 +0000</pubDate>
</item>
<item>
<title>What is exactly a &quot;tableViewIndex&quot;</title>
<link>https://overflow.efficy.io/?qa=4176/what-is-exactly-a-tableviewindex</link>
<description>&lt;p&gt;Hello Efficy Team, &lt;/p&gt;

&lt;p&gt;The question is quite simple. What is exactly a &quot;tableViewIndex&quot; ? &lt;br&gt;
We can find the tableViewIndex in multiple serverJs function, as parameters.&lt;/p&gt;

&lt;p&gt;I guess it is the &quot;id of the table&quot; from the sys_tableviews. Is it well the table id returned by the function Efficy.entityCatalog.tableIdFromEntityDetail (and some other functions) ? &lt;/p&gt;

&lt;p&gt;Then, how to use it ? Can you give us concrete exemple of cases where we should use this parameter with another value than 0 ?&lt;/p&gt;

&lt;p&gt;Thanks in advance for the enlightenment, &lt;/p&gt;

&lt;p&gt;Loïc &lt;/p&gt;
</description>
<category>WorkFlow / Serverscript</category>
<guid isPermaLink="true">https://overflow.efficy.io/?qa=4176/what-is-exactly-a-tableviewindex</guid>
<pubDate>Thu, 25 Apr 2019 19:58:25 +0000</pubDate>
</item>
<item>
<title>Efficy 11: Different ways to call a serverside script (which is the best one)</title>
<link>https://overflow.efficy.io/?qa=4171/efficy-different-ways-call-serverside-script-which-the-best</link>
<description>&lt;p&gt;Hi guys,&lt;/p&gt;

&lt;p&gt;We can call a serverscript in multiple ways (and we can find both in the standard).&lt;br&gt;
For now (Efficy 11.2), and for the futur, Is there a way better than the others ? Is there a depracate way ?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Utils.runServerJsAjax&lt;/li&gt;
&lt;li&gt;Utils.runScriptAjax2&lt;/li&gt;
&lt;li&gt;$.ajax({&lt;br&gt;
url: ...,&lt;br&gt;
method: ...,&lt;br&gt;
data: ...&lt;br&gt;
}).done(function (html) {&lt;br&gt;
...&lt;br&gt;
});&lt;/li&gt;
&lt;/ul&gt;
</description>
<category>Efficy/ Client side</category>
<guid isPermaLink="true">https://overflow.efficy.io/?qa=4171/efficy-different-ways-call-serverside-script-which-the-best</guid>
<pubDate>Thu, 25 Apr 2019 14:11:07 +0000</pubDate>
</item>
<item>
<title>Get only what's change during the edit context</title>
<link>https://overflow.efficy.io/?qa=4023/get-only-whats-change-during-the-edit-context</link>
<description>&lt;p&gt;Hello Efficy Team, &lt;/p&gt;

&lt;p&gt;I got a complex process where I need to &lt;em&gt;do something&lt;/em&gt; with the &quot;new element&quot; of a detailDataSet, or the deleted elements of the detailDataSet during the edit context.&lt;/p&gt;

&lt;p&gt;What is the best way retrieve only those element ? &lt;/p&gt;

&lt;p&gt;Here is what I did : &lt;/p&gt;

&lt;pre&gt;&lt;code&gt;    var k_project = Efficy.getEditKey(editHandle);
var relationTable = Efficy.entityCatalog.getRelationEntityTableName(ntProj, TEntityHandle);
var kElement = Efficy.entityCatalog.keyFieldName(TEntityHandle);

var dsDetails = Efficy.sqlQueryDataSet('select * from ' + relationTable + ' where k_project = :param1', k_project, 45);
var newDetails = Efficy.getDetailDataSet(editHandle, TEntityHandle);

var changesInTheEditContext = [];

if(dsDetails || !dsDetails.isEmpty()) {

    // the project is already committed. We need to get only the &quot;new&quot; one
    // for that, we filter the &quot;new one&quot; based on the &quot;old one&quot;

    var existing = [];
    dsDetails.first();
    while (!dsDetails.eof()) {
        existing.push(dsDetails.fieldByName(kElement).asFloat);
        dsDetails.next();
    }

    // ho yeah it is ugly. But seems that &quot;not in ()&quot; does not work
    newDetails.filter = kElement +' &amp;lt;&amp;gt; ' + existing.join(' AND ' +  kElement +  ' &amp;lt;&amp;gt; ');
    newDetails.FilterOptions = existing.length;
    newDetails.Filtered = true;

}

// then we get, for each &quot;new one&quot;, useful information's : entity, key, name

if(newDetails.isEmpty() || !newDetails) return false;
newDetails.first();

while(!newDetails.eof()) {

    changesInTheEditContext.push({
        entity : Efficy.entityCatalog.getEntityName(TEntityHandle),
        key : newDetails.fieldByName(kElement).asFloat,
        name : getName(newDetails.fieldByName(kElement).asFloat, TEntityHandle),
        operation : 'add'
    })

    newDetails.next();
}

newDetails.Filtered = false;

// we also need to detect the opposite : a contact deleted during the edit context
// we use the same ticks, but in the opposite (current detailDataSet filter the SQL)

if(dsDetails || !dsDetails.isEmpty()) {

    var fromRelationTable = [];

    newDetails.first();
    while (!newDetails.eof()) {

        fromRelationTable.push(newDetails.fieldByName(kElement).asFloat);
        newDetails.next();

    }

    // ho yeah it is ugly. But seems that &quot;not in ()&quot; does not work
    dsDetails.filter = kElement +' &amp;lt;&amp;gt; ' + fromRelationTable.join(' AND ' +  kElement +  ' &amp;lt;&amp;gt; ');
    dsDetails.FilterOptions = fromRelationTable.length;
    dsDetails.Filtered = true;

    if(dsDetails.isEmpty() || !dsDetails) return false;
    dsDetails.first();

    while(!dsDetails.eof()) {

        changesInTheEditContext.push({
            entity : Efficy.entityCatalog.getEntityName(TEntityHandle),
            key : dsDetails.fieldByName(kElement).asFloat,
            // name : getName(newDetails.fieldByName(kElement).asFloat, TEntityHandle), -- we don't need the name, he's already displayed
            operation : 'delete'
        })

        dsDetails.next();
    }

    dsDetails.Filtered = true;

}

return changesInTheEditContext;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Is there, by any chance, a way to get those change in a more &quot;Efficy way&quot; than comparing two dataSet ? &lt;/p&gt;

&lt;p&gt;Regards,&lt;/p&gt;

&lt;p&gt;Loïc&lt;/p&gt;
</description>
<category>WorkFlow / Serverscript</category>
<guid isPermaLink="true">https://overflow.efficy.io/?qa=4023/get-only-whats-change-during-the-edit-context</guid>
<pubDate>Tue, 12 Mar 2019 07:49:17 +0000</pubDate>
</item>
<item>
<title>Flexmail: missing contact status once the campaign is sent</title>
<link>https://overflow.efficy.io/?qa=3992/flexmail-missing-contact-status-once-the-campaign-is-sent</link>
<description>&lt;p&gt;I added a new status in the lookup &lt;code&gt;LK_PUBL_STATUS&lt;/code&gt; but if I select it in a new personalized email, the contact status is not assigned to the selected value.&lt;/p&gt;
</description>
<category>WorkFlow / Serverscript</category>
<guid isPermaLink="true">https://overflow.efficy.io/?qa=3992/flexmail-missing-contact-status-once-the-campaign-is-sent</guid>
<pubDate>Thu, 28 Feb 2019 09:54:33 +0000</pubDate>
</item>
<item>
<title>[Solution] Don't be fooled by parseInt()</title>
<link>https://overflow.efficy.io/?qa=3874/solution-dont-be-fooled-by-parseint</link>
<description>&lt;p&gt;Hello Team, &lt;/p&gt;

&lt;p&gt;I would like to share with you a problem I encountered yesterday.&lt;br&gt;
If, like me, you never worked on old version of Javascript, with old browser, you could be used to do that : &lt;/p&gt;

&lt;pre&gt;&lt;code&gt;parseInt(&quot;011&quot;) // return 11
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;But Efficy use not the same version of Javascript as your browser. He use a version before ECMA5.&lt;/p&gt;

&lt;p&gt;So, this : &lt;/p&gt;

&lt;pre&gt;&lt;code&gt;parseInt(&quot;011&quot;) // return 9
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The explanation is simple. Before ES5, the base used by default was not always 10 (it was depending the string you wanted to parse). The documentation is clear about that : &lt;a rel=&quot;nofollow&quot; href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseInt&quot;&gt;parseInt sur MDN&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So the solution is : &lt;/p&gt;

&lt;pre&gt;&lt;code&gt;parseInt(&quot;011&quot;, 10) // return 11
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Or, even better, the Efficy function : &lt;/p&gt;

&lt;pre&gt;&lt;code&gt;strToFloat(&quot;011&quot;) // ALWAYS return 11
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;I hope you won't spend as much time as I did :) &lt;/p&gt;

&lt;p&gt;Loïc&lt;/p&gt;
</description>
<category>WorkFlow / Serverscript</category>
<guid isPermaLink="true">https://overflow.efficy.io/?qa=3874/solution-dont-be-fooled-by-parseint</guid>
<pubDate>Wed, 23 Jan 2019 10:51:51 +0000</pubDate>
</item>
<item>
<title>Efficy 11: What  is the best way to override standard serverjs scripts like flexmail ?</title>
<link>https://overflow.efficy.io/?qa=3448/efficy-what-best-override-standard-serverjs-scripts-flexmail</link>
<description>&lt;p&gt;Dear all,&lt;/p&gt;

&lt;p&gt;I need to change some part of flexmail integration for a customer, like adding the contact title to the contact sent to flexmail.&lt;/p&gt;

&lt;p&gt;I looked at the sample custom and the buildnotes of Efficy 11, but I didn't find the proper way to just change the &quot;fields.js&quot; file&lt;/p&gt;

&lt;p&gt;is it like the macro files, can I just copy past the fields.js to my custom folder &quot;serverjs/flexmail&quot; or do I have to completly copy the flexmail folder in my custom to do the modification ?&lt;/p&gt;

&lt;p&gt;Best Regards,&lt;br&gt;
Stéphane&lt;/p&gt;
</description>
<category>WorkFlow / Serverscript</category>
<guid isPermaLink="true">https://overflow.efficy.io/?qa=3448/efficy-what-best-override-standard-serverjs-scripts-flexmail</guid>
<pubDate>Fri, 03 Aug 2018 12:29:00 +0000</pubDate>
</item>
</channel>
</rss>