In a Business Rule Dot-Walking with getValue() or getDisplayValue() are not showing any Values

Lucas Domberg
Tera Contributor

Hi Community,

I am trying to set the "Needed at" date on a Request Item via a Business Rule. I am using the following code:

(function executeRule(current, previous /*null when async*/ ) {
    gs.log("This is the Request sys_id: " + current.getUniqueValue() + " This is the Requested For: " + current.u_requested_for.name.getDisplayValue() + " This is the effective start Date: " + current.u_requested_for.u_effective_start_date.getDisplayValue(), "LDOM");
	
    var neededat = current.u_requested_for.u_effective_start_date.getDisplayValue();
	gs.log("Needed at: " + neededat, "LDOM");
    current.setValue('request.u_due_date', neededat);

})(current, previous);

Getting the Request ID in the Log Statement works fine but I can neither get the name of the Requested For nor the actual Effective Start Date on the "Requested For" user, which should be the value to fill the needed at date. At this point I should say that this RITM is created by an Onboarding Order Guide and the Business Rule itself is reacting to an Insert on the sc_req_item table where the condition just applies to the field "order_guide" being filled with our "Employee Onboarding" value of our Onboarding Order Guide.

I played around with getValue('current.u_requested_for.u_effective_start_date') and current.u_requested_for.u_effective_start_date.getDisplayValue() but either it's giving me a blank value or it's just giving me a "null" value in my log statements.

If I open the user there definitely is a value in the field.

Any thoughts on how to get my actual values? I know this might be a very simple solution but my brain is rather blocked at the moment.

 

Kind Regards

Lucas

8 REPLIES 8

Hi Jaspal,

 

The Business Rule is running on the table "sc_req_item" and there is no ootb "requested_for" field.

 

But I will try to simply let the business rule run on the request table directly because there I have the "requested_for" field. Maybe it's a problem with the customized field.

 

 

I can't just change the table since the condition runs on the "order_guide" field on the sc_req_item table. So it has to stay the "sc_req_item" table.

 

Any ideas on how to get this working?

Hi Lucas,

 

To understand the exact scenario it is as below.

1. A before Business rule is on sc_req_item table which runs on insert/update 

2. There is a need to update date field.

3. You are getting logs but it is not updating the field value.

Confirm if any of above understanding is incorrect.

Hi Jaspal,

 

It's an after Business Rule running on insert but the rest is correct.