Calculated field script not updating?

Brian Bouchard
Mega Sage

First time using a calculated field, so I'm not sure if I'm doing something wrong here.

I have a calculated field that concaenates 2 other fields and is used in a list collector or a record producer in the service catalog.

When I first created the field I found I had an arror where I concated the name field instead of the u_name field on the table.  I fixed that, so my calculated value field now looks like the following

(function calculatedFieldValue(current) {
	// Add your code here
var ans = current.u_requestable_access = current.u_name.getDisplayValue() + " (" +current.u_func_access_display + ")";
	return ans;  // return the calculated value
})(current);

 

However, when I submit the record producer I'm seeing the following error in the log:

org.mozilla.javascript.EcmaError: "name" is not defined.
Caused by error in <refname> at line 4

1: (function calculatedFieldValue(current) {
2:
3: // Add your code here
==> 4: var ans = name + " " +func_access_display;
5: return ans; // return the calculated valu
6:
7: })(current);


I've tried runnign cache.do, but that didn't seem to help.

 

Is there some sort of trick to updating the calculated value once you've set it once?

2 REPLIES 2

Veer MS
Kilo Guru

Hi, Brian,

Try the below code :

current.variables.u_name.getDisplayValue()

This should work.

Thanks

Veer

Brian Bouchard
Mega Sage

I don't think the script in the record producer is my issue, as the error that is coming out seems to be related to the calculated field on that table I'm reading that variable from.  The code that I shared was in the calculated field, and that table and calculated field appear fine. It's not until I submitt herecord producer that I see this error, though, even though it appears to be coming from the calculated field.

 

Not sure if that all makes sense, but the bottom line is the error seems to be coming from the calculated field and is showing code that doesn't exist anymore, because i have updated the code on that field.