Community Tip - Want the oppurtunity to discuss enhancements to PTC products? Join a working group! X
Created a userpicker in a custom datautility and regiseterd it on a string attribute. Picker renders correctly in UI. On selecting user clicking finish windchill throws error for custom callback function saying that we cannot set value for null. Also mc.getRawValue() always returns null in the below code.
//Get datavalue method of datautilty
public Object getDataValue(String component_id, Object object, ModelContext mc) throws WTException {
buildUserPickerConfig(component_id, mc);
Object localObject = null;
System.out.println(mc.getRawValue());
if (mc.getRawValue() != null)
{
localObject = mc.getRawValue();
defaultProps.put(PickerRenderConfigs.DEFAULT_HIDDEN_VALUE, localObject.toString());
} else
{
localObject = "";
}
PickerInputComponent pic = new PickerInputComponent("UserPicker",localObject.toString(), defaultProps);
pic.setColumnName(component_id);
return pic;
}
//Callback JS
function userPickerCallback(objects, pickerID)
{
var updateHiddenField = document.getElementById(pickerID);
alert(updateHiddenField);
var myJSONObjects = objects.pickedObject;
for(var i=0; i< myJSONObjects.length;i++) {
var oid = myJSONObjects[i].oid;
alert(oid);
// Here “fullName” is the displayAttribute requested
updateHiddenField.value=oid;
}
}
Error Screenshot.
Solved! Go to Solution.
public void buildUserPickerConfig(final String component_id, | |||
final ModelContext mc) throws WTException { | |||
// HashMap<String, Object> defaultProps = new HashMap<String, Object>(); | |||
defaultProps.put("pickerId", "userPluralID"); | |||
defaultProps.put("objectType", "wt.org.WTUser"); | |||
mc.getDescriptor().setProperties(defaultProps); | |||
} |
This solved it. I was adding callback in the config. I removed it and it worked. The default callback function works I guess.
Praveen,
Are you specifying any pickerCallback in the dataUtility? Also set the values for PickerRenderConfigs.PICKER_ATTRIBUTES with the required attributes that you want to show in the user interface and the value that needs to be persisted in database.
Regards,
Bhushan
public void buildUserPickerConfig(final String component_id, | |||
final ModelContext mc) throws WTException { | |||
// HashMap<String, Object> defaultProps = new HashMap<String, Object>(); | |||
defaultProps.put("pickerId", "userPluralID"); | |||
defaultProps.put("objectType", "wt.org.WTUser"); | |||
mc.getDescriptor().setProperties(defaultProps); | |||
} |
This solved it. I was adding callback in the config. I removed it and it worked. The default callback function works I guess.
Yes, OOTB callback function is provided, you can write your own if you need a different display or internal value.
Can you mark this thread as answered with your solution so that it helps others in future.
how did u remove that from config?