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

Aniket Chavan
Tera Sage
Tera Sage

Hello @cpinedatx94 

Can you please share your business rule code so that we can get idea here exactly what is going wrong in this scenario and any other related details if you missed in first place which can help us to understand the requirement better.

Thanks,
Aniket.

Peter Bodelier
Giga Sage

Hi @cpinedatx94 

 

Please provide the script you've been trying with.


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

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

	// Add your code here
var workorderParent=current.parent.getRefRecord();
workorderParent.u_submit_am=current.u_am_submit+'';
workorderParent.u_submit_client=current.u_task_submit_client+'';
workorderParent.u_interview_client=current.u_task_client_interview+'';
workorderParent.u_interview_rs=current.u_task_rs_interview+'';
workorderParent.update();
})(current, previous);

 

This script auto fills parent work fields based on child task order.

 

Issue is there a 5 takes one the work order. Are with the same fields. One person is responsible for filling in one field. Which then auto populates into the parent work order. But the issue arises when there task has blank fields which other people have filled in on there own task. Leading to already filled in fields being erased on the parent work order.

Sorry i know this sounds REALLY confusing!

Thanks

There you go:

 

 

(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.