Expand my Community achievements bar.

SOLVED

Simplication of Java Script

Avatar

Level 4

in a livecycle dynamic form use this java script

if

   (Table92.Row1.Cell1.rawValue !== null && Table92.Row1.Cell2.rawValue !== null)

   {

          this.rawValue = "Completion of construction work for the " + Table92.Row1.Cell1.rawValue + " phase of instalment and request for release of " + Table92.Row1.Cell2.rawValue + " phase of instalment";

   }

if

   (Table92.Row1.Cell1.rawValue !== null && Table92.Row1.Cell2.rawValue == null)

   {

          this.rawValue = "Completion of construction work for the " + Table92.Row1.Cell1.rawValue + " phase of instalment and request for release of .................... phase of instalment";

   }

if

   (SfCC.Table89.Row5.Table92.Row1.Cell1.rawValue == null && SfCC.Table89.Row5.Table92.Row1.Cell2.rawValue !== null)

   {

          this.rawValue = "Completion of construction work for the .......................... phase of instalment and request for release of " + SfCC.Table89.Row5.Table92.Row1.Cell2.rawValue + " phase of instalment";

   }

if

   (SfCC.Table89.Row5.Table92.Row1.Cell1.rawValue == null && SfCC.Table89.Row5.Table92.Row1.Cell2.rawValue == null)

   {

          this.rawValue = "Completion of construction work for the .......................... phase of instalment and request for release of ................... phase of instalment";

   }

Please help me to short the java script ( i have very limited knowledge of java script)

1 Accepted Solution

Avatar

Correct answer by
Level 10

You can minimize it this way:

var oCell1 = Table92.Row1.Cell1,

oCell2 = Table92.Row1.Cell2,

cTxt = "Completion of construction work for the ";

if (oCell1.isNull) {

cTxt += oCell2.isNull ? (".......................... phase of instalment and request for release of ................... phase of instalment") : (".......................... phase of instalment and request for release of " + oCell2.rawValue + " phase of instalment");

} else {

cTxt += oCell2.isNull ? (oCell1.rawValue + " phase of instalment and request for release of .................... phase of instalment") : (oCell1.rawValue + " phase of instalment and request for release of " + oCell2.rawValue + " phase of instalment");

}

this.rawValue = cTxt;

or even more

var oCell1 = Table92.Row1.Cell1,

oCell2 = Table92.Row1.Cell2,

cTxt = "Completion of construction work for the ",

cDummy = "...................",

cTxt2 = " phase of instalment and request for release of ",

cTxt3 = " phase of instalment.";

if (oCell1.isNull) {

cTxt += oCell2.isNull ? (cDummy + cTxt2 + cDummy + cTxt3) : (cDummy + cTxt2 + oCell2.rawValue + cTxt3);

} else {

cTxt += oCell2.isNull ? (oCell1.rawValue + cTxt2 + cDummy + cTxt3) : (oCell1.rawValue + cTxt2 + oCell2.rawValue + Text3);

}

this.rawValue = cTxt;

View solution in original post

3 Replies

Avatar

Correct answer by
Level 10

You can minimize it this way:

var oCell1 = Table92.Row1.Cell1,

oCell2 = Table92.Row1.Cell2,

cTxt = "Completion of construction work for the ";

if (oCell1.isNull) {

cTxt += oCell2.isNull ? (".......................... phase of instalment and request for release of ................... phase of instalment") : (".......................... phase of instalment and request for release of " + oCell2.rawValue + " phase of instalment");

} else {

cTxt += oCell2.isNull ? (oCell1.rawValue + " phase of instalment and request for release of .................... phase of instalment") : (oCell1.rawValue + " phase of instalment and request for release of " + oCell2.rawValue + " phase of instalment");

}

this.rawValue = cTxt;

or even more

var oCell1 = Table92.Row1.Cell1,

oCell2 = Table92.Row1.Cell2,

cTxt = "Completion of construction work for the ",

cDummy = "...................",

cTxt2 = " phase of instalment and request for release of ",

cTxt3 = " phase of instalment.";

if (oCell1.isNull) {

cTxt += oCell2.isNull ? (cDummy + cTxt2 + cDummy + cTxt3) : (cDummy + cTxt2 + oCell2.rawValue + cTxt3);

} else {

cTxt += oCell2.isNull ? (oCell1.rawValue + cTxt2 + cDummy + cTxt3) : (oCell1.rawValue + cTxt2 + oCell2.rawValue + Text3);

}

this.rawValue = cTxt;

Avatar

Level 4

thank you very much.

Its working..............

Avatar

Level 4

Sir

please suggest something so that font of Table92.Row1.Cell2 & Table92.Row1.Cell2 will also copy after calculation in script.