6 Replies Latest reply on Sep 14, 2018 12:59 PM by iiliev

    apply a function to 2 attributes ?

    zdingelit Novice
      I am newbie in Javascript Dev/vRO
      I need some help to use this script.
      attrib1 variable contains /Fox/Sdf/Acd/Opf/ > after formatting the output is SDF_ACD_OPF
      attrib2 variable contains /Fox/Aqsz/Dre/Pqf/ > after formatting the output is AQSZ_DRE_PQF
      The code works for on attribute but I want to create a function that is used on the 2 attributes and store the result in attrib1 and attrib2
      How to apply the function to each attribute ?
      here is my code :
       str = attrib1  function formatEntity (str) { // delete /Alpha/Dr/Oerd/ // delete Alpha/Aqs/ str = str.replace( /\/Alpha\/Dr\/Oerd\/?/gi,""); str = str.replace( /\/Alpha\/Aqs\/?/gi,"");  //replace           ----/Fox/Sdf/---- by Sdf/ str = str.replace( /\/Fox\/Sdf\//g,"Sdf/"); //replace          ----/Fox/Apcr/---- by Apcr/ str = str.replace( /\/Fox\/Apcr\//g,"Apcr/"); //replace          ----/Fox/Aqsz/---- by Aqsz/ str = str.replace( /\/Fox\/Aqsz\//g,"Aqsz/"); //replace          ----/Oxa/Abdr/---- by  Abdr/ str = str.replace( /\/Oxa\/Abdr\//g,"Abdr/"); // UpperCase the string str = str.replace( /\w/gi, function (x) {     return x.toUpperCase(); }); // delete the last  "/" str = str.replace(/\/$/g, ""); // replace remain "/" by  _ str = str.replace(/\//g, "_"); System.log(str) }
      Merci !