OnSubmit Field and form rule script multiplies strings
We have OnSubmit script as written below, which should take the current subject of an service request and merge it with employee name on submit, so that ticket subject is:
"orig_subject - Employee_name".
This is a problem, if you miss to fill any required field and SD warns you that you need to fill some of the required fields, the resulting subject string is multiplied like:
"SUBJECT - EMPLNAME - EMPLNAME - EMPLNAME". The more times you miss a required field and needs to re-submit, the longer the subject is.
How to fix it, so that it is used only when all fields are filled correctly ?
var subj=$CS.getValue("SUBJECT");
var empl=$CS.getValue("ServiceReq_1201_UDF_CHAR3");
$CS.setValue("SUBJECT",subj + " - " + empl);
Thanks for any input.
JP
New to ADSelfService Plus?