hcl-bot
January 30, 2013, 10:37am
1
I have a computed when composed field that computes even on existing documents.
I need to look up up the name of the user when the document is created to save the department they work in, however if it is an older document and that person no longer exist in the NAB I get a error “Field: ‘DepartmentCodeLookup’: Entry not found in index”.
Why is this field not obeying the computed when compose type.
Here is the code for the computed value…
temp :=@DbLookup ( “Notes”:“”;@ServerName :“names.nsf”;“PeopleLookup”; EmpNameLookup; 4);
@If ( EmpNameLookup = “”;“”;
@If ( @IsError ( temp ); ""; temp ));
@SetField ( “DepartmentCodeLookup”; temp );
@SetField ( “Department”; temp )
Subject: You are not assigning the result of the @If test…
As your code stands, temp is never changed, since you are not assigning the result of the @if test back to it.
Subject: A few things
How do you have a computed-when-composed field that works “even on existing documents”?
Which field is your code in?
@If ( EmpNameLookup = “”;“”;
@If ( @IsError ( temp ); “”; temp ));
There is no need to nest @If like this. It can be simplified to @If (EmpNameLookup=“”;“”;@IsError (temp);“”;temp);
It would be better to check if EmpNameLookup=“” before you do the @DbLookup to save processing.
As Wayne says, you are not doing anything to the temp variable between @DbLookup and @Setfield
I would write the code as:
temp := @If (EmpNameLookup=“”; “” ; @DbLookup ( “Notes”:“”;@ServerName :“names.nsf”;“PeopleLookup”; EmpNameLookup; 4));
temp := @If (@IsError (temp); “” ; temp);
@SetField ( “DepartmentCodeLookup”; temp );
@SetField ( “Department”; temp )
I hope this helps,
Phil