This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

DEVELOPERS FORUM - How to get next possible Lifecacle State with ARAS API ?

JensRollenmueller - Wednesday, February 27, 2013 8:28 AM:

Hello Community,

how can I get the next possible lifecycle states of an Aras Item using API ? My problem is that I will get all next states and not only the "allowed" - there must be an identity of the current user.

I found no API which returns a List of assigned Identities.

// Returnvalue
List<string> nextLifecycleStates = new List<string>();

// Ermitteln des Aras-Items zum PLM Object
Innovator Inno = this.getInnovator();

// read the current state of my item
string currentState = this.getProperty("current_state");

// read the transformations
Item transitionItem = Inno.newItem("Life Cycle Transition", "get");
transitionItem.setProperty("from_state", currentState);
Item transitionItems = transitionItem.apply();

if (!transitionItems.isError())
{
 for (int iCurrentItem = 0; iCurrentItem < transitionItems.getItemCount(); iCurrentItem++)
 {
  Item currentItem = transitionItems.getItemByIndex(iCurrentItem);

  // Get the "To-State Item"
  string toStateItemID = currentItem.getProperty("to_state");
  Item toStateItem = Inno.getItemById("Life Cycle State", toStateItemID);

  // Add to result
  if(!nextLifecycleStates.Contains(toStateItem.getProperty("name","")))
  {
   nextLifecycleStates.Add(toStateItem.getProperty("name",""));
  }
 }
}

// Returnvalue
return nextLifecycleStates;



PeterSchroer - Wednesday, February 27, 2013 8:41 AM:

Hello Jens,   I do not remember the answer to either question (how to get allowed next LC states,  or   how to get Identity List), but I have done both in the past,  so I know it is possible.    I can tell you first how I find the answer.     The standard client has a dialog which somehow shows the actual allowed next LifeCycle states for the selected item and for the current user.    Normally I will look in the code of the client to answer most of my own questions.    Sometimes you will see several calls with logic in JS,  other times you will see 1 call to the server using a special method name.      The client JS libraries are where I find the best approaches to solving ptoblems.

 

--peter



JensRollenmueller - Tuesday, March 12, 2013 1:34 PM:

Hello Thanks,

I found it thanks -

<Item type="Part" id="3A76505FA2E347D89C96F30A12E2DDB9" action="getItemNextStates" />

// Jens