Remove newline from description

priyankagavali
Tera Contributor

I want to remove the extra new line getting in description field .
Am trying to set description field using below script (part of script) but every time i change the group and save record one extra newline is added between manual description and group description.

ex. (it should like)
manualdescription
Description from group:test

(after change group and save the form )
manualdescription

Description from group:test

Script:

 

 

 var descValue = current.getValue('u_description');
  var stringValue = "Description from group:";
  var grpDescription = current.u_group.description.toString();
   

    if (!gs.nil(descValue) && !descValue.includes(stringValue) && !gs.nil(grpDescription)) {

        current.setValue('u_description', descValue + "\n" + stringValue + " " + grpDescription);
    } else if (!gs.nil(descValue) && !gs.nil(grpDescription)) {

        if (descValue.includes(stringValue)) {

            var manualDescValue = descValue.split(stringValue)[0].toString();

            // manualDescValue.trim();
            manualDescValue.replace(/\n/g, '');
          

            if (gs.nil(manualDescValue)) {

                current.setValue('u_description', stringValue + " " + grpDescription);
            } else {
                current.setValue('u_description', manualDescValue + "\n" + stringValue + " " + grpDescription);
            }
        } else {

            current.setValue('u_description', descValue + "\n" + stringValue + " " + grpDescription);
        }
    }

 

1 REPLY 1

AshishKM
Kilo Patron
Kilo Patron

Hi @priyankagavali , 

 

Add gs.log in each current.setValue() and check which section is executing after first update, second update ..... etc. and check the result. I think, the first update is adding a line and this line is part of manual description for next update and it's keep continue. 

 

-Thanks,

AshishKM

 


Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution