How can I get the ID of a Status based on its value?

Carlos Tichy December 5, 2018

Hi,

I have created a new Status "Assigned" in my Object Schema; it has the ID 87.

Currently, I'm scripting to update the Status of a referenced object to "Assigned", but I don't want to pass the argument as Integer, as follows:

// Sets the Status of the Device to Active
def obTriageDeviceStatus = objectFacade.loadObjectAttributeBean(deviceObject.getId(), "Status").createMutable() //The name of the attribute
def valueDeviceStatus = obTriageDeviceStatus.getObjectAttributeValueBeans()
def valueDeviceStatusBean = obTriageDeviceStatus.createObjectAttributeValueBean()
valueDeviceStatusBean.setValue(objectTypeAttributeFacade.loadObjectTypeAttributeBean(obTriageDeviceStatus.getObjectTypeAttributeId()), 87) //the default valueDeviceStatus to set
valueDeviceStatus.clear()
valueDeviceStatus.add(valueDeviceStatusBean);
obTriageDeviceStatus.setObjectAttributeValueBeans(valueDeviceStatus)


but something like:

// Sets the Status of the Device to Active
def obTriageDeviceStatus = objectFacade.loadObjectAttributeBean(deviceObject.getId(), "Status").createMutable() //The name of the attribute
def valueDeviceStatus = obTriageDeviceStatus.getObjectAttributeValueBeans()
def valueDeviceStatusBean = obTriageDeviceStatus.createObjectAttributeValueBean()
valueDeviceStatusBean.setValue(objectTypeAttributeFacade.loadObjectTypeAttributeBean(obTriageDeviceStatus.getObjectTypeAttributeId()), GET_STATUS_ID("Assigned")) //the default valueDeviceStatus to set
valueDeviceStatus.clear()
valueDeviceStatus.add(valueDeviceStatusBean);
obTriageDeviceStatus.setObjectAttributeValueBeans(valueDeviceStatus)


Thus, making the code portable to other Object Schema.

 

Could somebody please give me a hand on that?

Thank you, very much,

Carlos

 

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events