Wiki Javascripts Examples

General information – Evaluate


These formulas can be copy pasted in DirectLink (Evaluate) This wil help for example to; transform, recalculate, renumber or replace data from your source file.

[value] = Is a columnheader

” = Check these; if you copy paste the formula 

If formula – If the value is something; do this else that

Option 1

return ( [F12] > 0 ) ? “debit” : “credit”;

Option 2

return ( [ns1:amntTp] == “D” ) ? “debit” : “credit”;

Option 3

return ( “[Periode]” == “2021/00” ) ? “CONV0” : “CONV”;

Date from Yesterday – If the file doesn’t have a column with a date

return (d => new Date(d.setDate(d.getDate() – 1)))(new Date()).toISOString().substring(0,10);

Skip Line Skip Lines with no values to be imported

to be used in <Office> 
return ([bedrag] > 0) ? “2TWIN” : “”;

Positive amount Make the amounts positive

return Math.abs( [Balance] )

Date – Reformatting date; year of 2 digits

var f7 = “[F7]”;
return  “20” + f7.substr(4,2) + f7.substr(2,2) + f7.substr(0,2);

IDMPS – DEBITCREDIT

MEMO – VRK in 1 file – op basis van VRK + regelnummer bepalen of het debit of credit is. CONV, bedrag bepaald debitcredit / VRK regelnummer bepaald debitcredit

 var f2 = “[F0][F2]”;

if (f2 == “0VRK”) {
  return “debit”;
}
else if (f2 == “1VRK”) {
  return “credit”;
}
else {
  return ([F12] > 0 ) ? “debit” : “credit”;
}

Return Value If value is > 0 than return 

a) Staat er altijd een integer getal 
return ( Number( “[F7]”.trim()) > 0 ) ? “001” : “”;

b) Kan het veld soms ook leeg zijn:  
return ( “[F7]”.trim().length > 0 ) ? “001” : “”;

If else – 

var pjsj = “[journal_id]”

if ( pjsj == “PJ”) {
return “[source]”;
}
else if ( pjsj == “SJ”) {
return “[source]”;
}
else {
return “”;
}

Concatenate multiple column text values

return “[Broker Cd]-[Polisnr]”

 

If the column Amount is left blank if no value is availble 

var debit = “[Debit]”.length > 0 ? Number(“[Debit]”) : 0;

var credit = “[Credit]”.length > 0 ? Number(“[Credit]”) : 0;

return debit + credit;

If no Date is available in the source

return (d => new Date(d.setDate(d.getDate() – 1)))(new Date()).toISOString().substring(0,10).split(“-“).join(“”);

return (d => new Date(d.setDate(d.getDate() – 1)))(new Date()).toISOString().substring(0,10);

× Heb je een vraag?