cancel
Showing results for 
Search instead for 
Did you mean: 

SDK: adding new value in custom fields

olivier_thiry
Participant
0 Kudos

Hello,

I wanted to add new value in custom field of the resource table... I used this code (taken from SDK example) :

//Create and fill request for CustomData Service

SaveCustomDataRequest request = new SaveCustomDataRequest();

List<CustomValue> customData = new ArrayList<CustomValue>();

CustomValue attribute = new CustomValue();

//Field name

attribute.setName("NOTIFICATION_NUMBER");

//value received from ERP

attribute.setValue(notification);

customData.add(attribute);

request.setCustomData(customData);

//table name

request.setObjectAlias("RESRCE");

request.setRef(handle);

customDataService.saveCustomData(request);

But get a validation error, complaining about no ModifiedDateTime providen... How can I initialize this date or avoid the validation ?

I also tried using the ResourceDOService, using the setCustomData method, but same error...

Thanks

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hello,

Please indicate what verion of ME (SP and patch) you are using and attach the stacktrace of the exception.

This exception can also occur if the passed resource does not exist. How did you get the initial reference in the first place?

In addition to that, can you check if there are any resources in your RESRCE table that do not have MODIFIED_DATE_TIME populated (where it is null)?

olivier_thiry
Participant
0 Kudos

I'm using ME 5.2.2.2, sdk 5.0.1.8, for the moment locally on my laptop for development.

There is no stack trace, I can just see the error when debugging :

com.sap.me.frame.domain.RequiredValueValidationException: class com.sap.me.domain.model.CustomFieldDOmodifiedDateTime

The resource exist, I do a read request before to check if the custom field has value or not. Anyway, it's a collaboration plug-in, executed when we change the resource status, so I got the resource handle as input ;o)

I can confirm there are some resource with custom value in other fields with date = null. It occurs when I'm saving the data in the GUI (so entering data's manually in custom field, do a save => fields are not initialized)

Regards

Former Member
0 Kudos

Hello,

I believe it was a bug and upgrade to the latest 5.2 SP /Patch (5.2.5.2) should help.

Thanks,

Mikhail

olivier_thiry
Participant
0 Kudos

unfortunately, it seems so, I already got this feedback from a ME specialist

We don't plan to upgrade to 5.2.5.2 for the moment, even if this version is installed on our ramp-up system.

I will use plan B, using MII and a command query in the meantime, even if I would prefer to use standard API...

Thanks

Regards