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 - Manually Promting a Part via a Method

Brian - Tuesday, April 7, 2009 7:08 PM:

Hi All,

Another new user joining the ranks.

I'm trying to manually trigger the Promotion of certain types of Parts from Preliminary to Released without having to use an ECN.

I thought that one way of doing this was by writing a method which can be applied to the Part in question.

Using the "Affected Item Promotion" method as a starting point I have come up with the following code:

Dim plmIdentity As Aras.Server.Security.Identity = Aras.Server.Security.Identity.GetByName("Aras PLM")
Dim PermissionWasSet As Boolean = Aras.Server.Security.Permissions.GrantIdentity(plmIdentity)
 
Dim innovator AS Aras.IOM.Innovator = Me.newInnovator()
Dim qry As Aras.IOM.Item
Dim thisErr As Aras.IOM.Item
Dim steps As Integer
 
Dim typ As String = Me.GetType()
 
qry = Me.newitem("Change Controlled Item", "get")
qry.setID(Me.getID())
Dim thisItem As aras.IOM.Item = qry.apply()
If (thisItem.isError()) Then
      thisErr = innovator.newError("Error getting Change Controlled Item: " & thisItem.getErrorDetail())
      Return thisErr
End If
 
  Dim toState As String
    If (thisItem.getProperty("state") = "Preliminary")
      toState = "Released"
      thisItem.setaction("promoteItem")
      thisItem.setproperty("state", toState)
      thisitem = thisItem.apply()
    End If
      If (thisItem.isError()) Then
        thisErr = innovator.newError("Error promoting Item: " & thisItem.getErrorDetail())
        Return thisErr
      End If
If (PermissionWasSet=true)    Then
      Aras.Server.Security.Permissions.RevokeIdentity(plmIdentity)
End If

 

When I run this method I get the following error:

"Error promoting Item: Internal Error: failed to get the transition to promote the Part from Preliminary to Released"

What has me baffled is that the "Affected Item Promotion" code that I started with does nothing to explicitly "get the transition" but it clearly works.

Any clues on what I could be missing?

Any input much appreciated.

Brian Pye



RobMcAveney - Tuesday, April 7, 2009 7:30 PM:

Hi Brian, and welcome.  That error message is trying to tell you that you cannot promote directly from Preliminary to Released because there is no such Transition defined in the Life Cycle Map.  Take a look at the "Part " Life Cycle Map (click on Life Cycle Maps on the TOC, search for the one named "Part" and open it) and I think you'll see what the problem is.  There are two ways to solve it: either modify your code to first promote to In Review then to Released or edit the Life Cycle Map and create a new Transition directly from Preliminary to Released.

Hope that helps -

Rob



cpenrod - Thursday, November 13, 2014 5:43 PM:

Hey Brian,

 

I'm trying to do a similar thing in Aras.  

I would like to be able to have a part go from "Preliminary" to "Released" automatically  if a certain part type is selected.  

For example if a user selects material under the part type then it will automatically be released.  

I know this post was back in 2007 and I'm working with Aras 10 so the code won't match up,

   but just wondering because you had luck with this in the past you would know some pointers.

 

Thanks

cpenrod



Brian - Tuesday, April 7, 2009 7:59 PM:

Hi Rob,

So easy when you understand the system methodology.

I added a step as you suggested to promote first to In Review and then to Released.

Works like a charm.

Thanks,

Brian.



fli - Monday, December 20, 2010 10:34 AM:

Gents,

Should I not be able to promote an activity like this ?

 

<AML>

<Item isNew="1" isTemp="1" type="activity2" action="edit" id="B2D0C61B88B9486A8173224D31B83075">

<percent_compl>100</percent_compl>

<current_state name="complete"</current_state>
<_quantity>1</_quantity>

<Relationships>

<Item type="Activity2 Deliverable" action="add">

<related_id>

<Item type="Part" action="get"><_item_id>5156099-1</_item_id></Item>

</related_id>

</Item>

</Relationships>

</Item>

</AML> 

 

Doesn't seem to work,  Anybody know why ?

BR/ Christoffer



fli - Wednesday, January 19, 2011 7:32 AM:

Hi

I just want to declare my question obsolete.

I wanted to premote the Activity when the staus = 100.  If will put the code if someone has the same problem.

Innovator inn = this.getInnovator();
string toState = ("complete");
string comment = ("Premoted by method");

// Retrieve the Activity2 Item
Item myAct = this.newItem(this.getType(),"get");
myAct.setID(this.getID());
myAct.setAttribute("select","percent_compl,state");
myAct = myAct.apply();

string myPercent_compl = myAct.getProperty("percent_compl","");
string myState = myAct.getProperty("state","");

      string logMsg = " myPrecent_coml " + myPercent_compl +" "+ myState +  "PermissionWasSet "+ PermissionWasSet  ;
      CCO.Utilities.WriteDebug("DR03",ref logMsg);
   
int done = 100;
   if (myPercent_compl == "100")  {
     
      myAct = myAct.unlockItem();
      myAct = myAct.promote(toState,comment);
      
      if (myAct.isError())       {     
        logMsg = " fejl " ;
         CCO.Utilities.WriteDebug("DR03",ref logMsg);
      
      }

}
return this;

 

BR/ Christoffer