Tuesday, September 25, 2018

Assign a static value with special characters to a field via script.

The static value needs to be entered in a Script Parameter. When this script is executed, script parameter won't decode it's value when loaded, unlike when hard coding the special characters on the code itself.
 
Example:
1. Create a User Event Script by navigating to Customization > Scripting > Scripts > New > User Event. In this example, setup an After Submit script.

2. Upload a javascript file with the following code:

function specialcharacter_afterSubmit()
{
    var context = nlapiGetContext();
    var special = context.getSetting('SCRIPT', 'custscript_specialcharacter');

    var rec = nlapiLoadRecord(nlapiGetRecordType(),nlapiGetRecordId());
    rec.setFieldValue('memo',special);
    nlapiSubmitRecord(rec);
}

3. On the Script Parameter tab, create a script parameter with the ID: _specialcharacter (or whatever is defined on the code you uploaded).  Select type Text and on the value, type the static value field. Example: "j'avais" or "l'impératif", "passé".
4. Deploy the script to a record.
 

No comments:

Post a Comment