How to add data to previous added data in description (script)

DIVI1
Tera Expert

I have to add data to description on record Producer script field.

 

Look it's not as easy as i though, I have part of script which is working properly: 

current.description = 'Store: ' + "\n" + producer.store.getDisplayValue() + "\n" +
 'Division: ' + "\n" + producer.division.getDisplayValue()  + "\n" + 'Department: ' + "\n" 
 + producer.department.getDisplayValue();
current.short_description = 'Allocation Request';

 

And after that I want to add extra data to current.description if:

else if(producer.b_baby_boys_outerwear == 'true'){
current.description = 'baby: ' + "\n" + producer.b_baby_boys_outerwear;
}

but description is overwritten...

 

How to get resolve?

1 ACCEPTED SOLUTION

_Gaurav
Kilo Sage

Hi @DIVI1 
If I have understood your requirement correctly, this needs to be done in a single go.

if(producer.b_baby_boys_outerwear == 'true'){
current.description = current.description + 'baby: ' + "\n" + producer.b_baby_boys_outerwear;
}

View solution in original post

8 REPLIES 8

Jaspal Singh
Mega Patron
Mega Patron

Hi,

You may need

else if(producer.b_baby_boys_outerwear == 'true'){
current.description = current.description+'  '+'baby: ' + "\n" + producer.b_baby_boys_outerwear;
}

Peter Bodelier
Giga Sage

Hi @DIVI1 

You can add like this:

 

else if(producer.b_baby_boys_outerwear == 'true'){
current.description += 'baby: ' + "\n" + producer.b_baby_boys_outerwear;
}

 

or 

 

else if(producer.b_baby_boys_outerwear == 'true'){
current.description = current.description + 'baby: ' + "\n" + producer.b_baby_boys_outerwear;
}

 

Whichever you prefer.

 


Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.

Not working unfortunately :

DIVI1_0-1697616905534.png

I don't know why 😮 

if(producer.division != 'b'){
current.assignment_group = 'ee1caba147c655108195c60cd36d43f5';
current.description = 'Store: ' + "\n" + producer.store.getDisplayValue() + "\n" +
 'Division: ' + "\n" + producer.division.getDisplayValue() + "\n" + 'Group: ' + "\n" 
 + producer.group.getDisplayValue() + "\n" + 'Department: ' + "\n" 
 + producer.department.getDisplayValue() + "\n" + 'Baby Group: ';
current.short_description = 'Allocation Request';
}
else if(producer.b_baby_boys_outerwear == 'true'){
current.description = current.description + 'baby: ' + "\n" + producer.b_baby_boys_outerwear;
}
b_baby_boys_outerwear - checkbox

If its a true false, you may need to treat it like this:

if(producer.division != 'b'){
current.assignment_group = 'ee1caba147c655108195c60cd36d43f5';
current.description = 'Store: ' + "\n" + producer.store.getDisplayValue() + "\n" +
 'Division: ' + "\n" + producer.division.getDisplayValue() + "\n" + 'Group: ' + "\n" 
 + producer.group.getDisplayValue() + "\n" + 'Department: ' + "\n" 
 + producer.department.getDisplayValue() + "\n" + 'Baby Group: ';
current.short_description = 'Allocation Request';
}
else if(producer.b_baby_boys_outerwear == true){
current.description = current.description + 'baby: ' + "\n" + producer.b_baby_boys_outerwear.toString();
}

Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.