Groovy PX:: is there a way to set null to a script object?

I need to set null to an object based on a certain condition.. However, when I use:

obj.setValueByAttId(ItemConstants.ATT_PAGE_TWO_LIST01, null);

or

obj.setValueByAttId(ItemConstants.ATT_PAGE_TWO_LIST01, ” “);

it doesn’t work.

Add Comment
4 Answer(s)
Best answer

Hey Himani,
                    I also came across same error, but this issue is resolved when I set List Attribute to ‘Required=No’ . Then input this code Object.setValue(“list15”,null);
This should work. Let me know if this works.

RE: Groovy PX:: is there a way to set null to a script object?

Agile Angel Answered on July 25, 2016.
Add Comment

Thanks  Saurabh 🙂

Agile User Answered on September 12, 2016.
Add Comment

I’ve gotten something similar to work.  This script nullifies a value during a Save As.

import com.agile.agileDSL.ScriptObj.*;
import com.agile.agileDSL.ScriptObj.AgileDSLException;
import com.agile.agileDSL.ScriptObj.IBaseObjectScriptObj;
import com.agile.api.*

void invokeScript(IBaseScriptObj obj) {
 String newNumber = obj.getNewNumber()
IAgileSession session = obj.getAgileSDKSession();
IItem newItem = (IItem) session.getObject(ItemConstants.CLASS_PARTS_CLASS, newNumber);

try{
IItem item = (IItem) session.getObject(IItem.OBJECT_TYPE, newNumber);
item.setValue(ItemConstants.ATT_PAGE_TWO_LIST23, null);

}catch (Exception e) {
 obj.logMonitor( e.getMessage() );
 }

obj.logMonitor(“Successful nullify List value” );
}

Agile Angel Answered on June 21, 2017.
Add Comment

Hi Matt, 

I tried your script on Agile 9.3.5  provided by you it works fine. But we have to change the required to No as mentioned by surabh then only it will work.

 

Regards,
Ganesh

Agile Angel Answered on June 22, 2017.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.