Forum Discussion
Hi amitosh,
It appears that the result of the aras.applyMethod function is a string containing the item data returned by the server method. To put this into a more readable format, I'd recommend using code like below to load it into an IOM Item object.
You can then perform all your logic and checks using the resItem variable. With that being said, we recommend against using direct SQL inside of a server method as it bypasses the standard Aras permission model. Instead you could perform all of this logic inside of your client method by taking advantage of the standard aras.getIdentityList() function. This will return a list containing all of the identities the currently logged in user belongs to. This list is also built off of a recursive query, so it will get all a list of identities even if the user is a member of a member of a member, etc. The code for this might look something like below.
Chris
Christopher Gillis
Aras Labs Software Engineer
- Amitosh_Tripathy7 years agoIdeator I
Thanks Chris. Works now!!!
But the method says it returns Item, is it returning containing the item data because its called from client?
public Item applyMethod( string methodName, string body )
getIdentityList - I tried this, but looping through the results and adding to the list took visible performance hit. Trying to convert to sql as I am going 2 levels in the Identity tree as you can see from SQL. Also, this piece of code need not go through access check as per our implementation
- christopher_gillis7 years agoNew Member
Hi amitosh,
I believe you're looking at the description of the applyMethod function available from the Innovator class in the IOM which does return an Item. The functions available from the aras object in a JavaScript method don't map directly with the functions available from the Innovator object in a server method even though some of them will occasionally share the same name.
A JavaScript representation of the Innovator object is available through a client method, however. If we use this Innovator object (available from aras.IomInnovator), a nicer way of writing the sample I provided in my last comment would instead be:
var res = aras.IomInnovator.applyMethod("NOV_Identity_Details", "body");
Since this function is called from an Innovator object, the return value is an Item object, so it will save you from needing to any manual conversion from a string to an Item.
Hope this helps!
Chris
- Amitosh_Tripathy7 years agoIdeator I
perfect! thanks for the update. Works as expected now [emoticon:c4563cd7d5574777a71c318021cbbcc8]