cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - If community subscription notifications are filling up your inbox you can set up a daily digest and get all your notifications in a single email. X

Created user picker using datautility throws error on callback function.

psampath
1-Newbie

Created user picker using datautility throws error on callback function.

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.

Screen Shot 05-28-15 at 11.09 AM.JPG

1 ACCEPTED SOLUTION

Accepted Solutions

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.

View solution in original post

4 REPLIES 4
BhushanNehe
14-Alexandrite
(To:psampath)

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.

BhushanNehe
14-Alexandrite
(To:psampath)

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?

Top Tags