Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

How come null can not be captured?

Not applicable
When the attribute (Dept) returned is null, I can not figure out how to check for the condition. If I don't append with blank, I will get an error. If I append blank, the result is "null".



function SetUserAttribute(sField, sAttribute)

{ var oParticipant = WorkItem.assignedTo;

if (oParticipant != null) {

var str = oParticipant.attributes.item(sAttribute);

if ((str != null) && (str != "null")) {

WorkItem.setFieldValue(sField,str+"");

}

}

}
1 Reply
Not applicable
Peter,



Since we are dealing with an Attribute object as our return value the conditional stmt to check for null should be against the property 'value'. As such...



void function SetUserAttribute(sField, sAttribute) {



var oParticipant = WorkItem.assignedTo;

if (oParticipant != null) {

var oAttrib = oParticipant.attributes.item(sAttribute);

if (oAttrib.value != null ) {

//WorkItem.setFieldValue(sField,str+"");

Agent.log(sField + " = " + oAttrib.value);

}

else

Agent.log(sField + " is EMPTY!");

}

}