Not able to set asset state to "approved" in iRAM
Hi
I am doing to set an asset status from draft to approved state.
When i am going to set the Approved state it showing an error message
Code snippet:
RAMAsset ramAsset =(RAMAsset)assets[k].getAsset();
String currState = ramAsset.getStateName().trim();
if(currState != null && currState.equalsIgnoreCase("Draft"))
{
String assetId = ramAsset.getGUID();
RAMAction ramActions1 = ramAsset.getAction();
if(true)
{
for (int j =0;j<1;j++)
{
ramAsset.setStateName("Approved");
System.out.println("Asset Id: "+ assetId+" Asset Name: "+ramAsset.getName());
Error message showing when it going to setStateName
Number of Draft Assets: 1525
com.ibm.ram.common.data.exception.RAMRuntimeException: The asset state can only be set by the server.
at com.ibm.ram.client.RAMAsset.setState(RAMAsset.java:4542)
at Catgory.CategorizeApprove.main(CategorizeApprove.java:124)
So can any please help me out to so that i can approve the assets .
I am doing to set an asset status from draft to approved state.
When i am going to set the Approved state it showing an error message
Code snippet:
RAMAsset ramAsset =(RAMAsset)assets[k].getAsset();
String currState = ramAsset.getStateName().trim();
if(currState != null && currState.equalsIgnoreCase("Draft"))
{
String assetId = ramAsset.getGUID();
RAMAction ramActions1 = ramAsset.getAction();
if(true)
{
for (int j =0;j<1;j++)
{
ramAsset.setStateName("Approved");
System.out.println("Asset Id: "+ assetId+" Asset Name: "+ramAsset.getName());
Error message showing when it going to setStateName
Number of Draft Assets: 1525
com.ibm.ram.common.data.exception.RAMRuntimeException: The asset state can only be set by the server.
at com.ibm.ram.client.RAMAsset.setState(RAMAsset.java:4542)
at Catgory.CategorizeApprove.main(CategorizeApprove.java:124)
So can any please help me out to so that i can approve the assets .
One answer
You can't directly set state. You must use the appropriate action to move to another state. Each state has a set of available actions, and each action then takes the asset to a different state.
See in the documentation for RAMAsset
There is getAvailableActions() to see what actions are available, and setAction() to set the action to perform when you send the asset for updating to the host.
See in the documentation for RAMAsset
There is getAvailableActions() to see what actions are available, and setAction() to set the action to perform when you send the asset for updating to the host.