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 - Method to Restrict Over ride path access to CM

Bryanjscott777 - Monday, December 7, 2015 3:40 PM:

Normal 0 false false false false EN-US X-NONE X-NONE MicrosoftInternetExplorer4

Hello,
I’m still fairly new to Aras Innovator 11 and have attended both the “Configuring Solutions” and “Developing Solutions” classes (not a programmer by trade), but I have run into what I thought would be a simple problem to resolve that has stumped me for a few days now.

I have a situation where coming off of a “Training” task (see below, hope picture shows up), I have an over-ride path (CM Training Update).  The problem is that I do not want anyone in the training group to be able to select this path, I want to limit the training group to using the “Refuse” option which will send a notification to me (CM) with the question allowing me to investigate and respond using “Delegate” back to the trainee(s) without disrupting the voting of everyone else.  If investigation does require an update, I want only “CM” to be able to initiate the “CM Training Update” path which will remove the training task from the balance of the training group which has not voted.

So my question is, can I create a server method that will look at the “created_by_id” or “modified_by_id” for the “CM Training Update” path (l am assuming “Pre Methods”) and if it doesn’t match the “CM” user id then return and error?
I have tried the following method attached to “Pre Methods” for the “CM Training Update” path but it appears to move right past it:
 
Innovator inn = this.getInnovator();

string u = this.getProperty("created_by_id","");

if (u != "62AD9C55AA4B4FDAB0212BB03B46D469") {
   
    return inn.newError("Insufficient Privileges to Vote CM Training Update, Please Vote Refuse");
}

return this;

I will also likely use the solution to make sure the curious minded trainees are not able to see what would happen if the selected the “Delegate” option.
Thank you in advance, and sorry if this question ends up being ridiculously simple…

 



Harsha - Monday, December 14, 2015 9:47 AM:

Hi,

In the above method 'this' refers to Activity item, not the item for which you are doing vote. Please see the below example to get the actual item from the Activity item:

Innovator inn = this.getInnovator();

Item _item = inn.newItem("Part","get");
_item.setProperty("select","id");

Item wfItem = inn.newItem("Workflow","get"); 
wfItem.setAttribute("select","id");

string actID  = this.getID(); 

Item wflProc = inn.newItem("Workflow Process","get");
wflProc.setAttribute("select","id");

Item wflAct = inn.newItem("Workflow Process Activity","get") ; 
wflAct.setProperty("related_id",actID) ;
wflAct.setAttribute("select","id");    
wflProc.addRelationship(wflAct);
wfItem.setRelatedItem(wflProc);
_item.addRelationship(wfItem);

_item = _item.apply();
  string createdById = _item.getProperty("created_by_id");

This is not tested, just an example.

Thank you,
Harsha

 



Bryanjscott777 - Friday, January 8, 2016 11:30 AM:

Hi Harsha,

Thank you for taking the time to respond, I am working on massaging your example into a working method, but due to my lack of programming skills, this may take some time.

I think that I understand the process that you have laid out to identify the Activity Item, but still need to figure out how to get it to point specifically to the "CM Training Update" path or the workflow, it would seem that I need to add some specifics into your example.

I will post an update when I have this working, thanks again for the response, this will save me a good deal of grief when it's working.

Bryan