Script keeps running on blank fields.

cpinedatx94
Tera Expert

I have a business rule that runs when a work order task is filled in, it also auto fills that same field to match in the parent work order. Ive already tried changing the script and ive tried changing it to not run on empty fields. But it keeps doing it.

The problem is multiple task all have the same fields and they are meant to be filled in one by one in each task. So everytime a new task field is filled in the other one gets erased how can i resolve this thanks.

1 ACCEPTED SOLUTION

Sorry, about that.

 

(function executeRule(current, previous /*null when async*/) {

var workorderParent=current.parent.getRefRecord();

if (JSUtil.notNil(current.u_am_submit)){
workorderParent.u_submit_am = current.u_am_submit+'';
}
if (JSUtil.notNil(current.u_task_submit_client)){
workorderParent.u_submit_client = current.u_task_submit_client+'';
}
if (JSUtil.notNil(current.u_task_client_interview)){
workorderParent.u_interview_client = current.u_task_client_interview+'';
}
if (JSUtil.notNil(current.u_task_rs_interview)){
workorderParent.u_interview_rs = current.u_task_rs_interview+'';
}

workorderParent.update();

})(current, previous);

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

View solution in original post

7 REPLIES 7

Thanks for the quick reply peter. Im getting an error.

"Could not save record because of a compile error: JavaScript parse error at line (5) column (39) problem = missing ) after condition (<refname>; line 5)"

Sorry, about that.

 

(function executeRule(current, previous /*null when async*/) {

var workorderParent=current.parent.getRefRecord();

if (JSUtil.notNil(current.u_am_submit)){
workorderParent.u_submit_am = current.u_am_submit+'';
}
if (JSUtil.notNil(current.u_task_submit_client)){
workorderParent.u_submit_client = current.u_task_submit_client+'';
}
if (JSUtil.notNil(current.u_task_client_interview)){
workorderParent.u_interview_client = current.u_task_client_interview+'';
}
if (JSUtil.notNil(current.u_task_rs_interview)){
workorderParent.u_interview_rs = current.u_task_rs_interview+'';
}

workorderParent.update();

})(current, previous);

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

Thank you so much for the help Peter. Worked like a charm!