‎05-03-2013 03:37 PM
I have just added a metacommand to User class in order to set some attributes.
How can I run this command for each user?
set cUser = getRoot.User For Each oUser in cUser .....? Next
Andrea G.
Solved! Go to Solution.
‎06-03-2013 11:40 AM
Ciao andrea,
as I already told you, there is no need to create a metaCommand to run a macro.
You can run it directly.
Then, if you read my last post, you should have the answer to your problem :
set cUser=getRoot.getSelection("Select User Where Name Like '#giova#' And [Repository Access Mode] Not='4'") set myMacro = MegaEnv.GetMacro("SetDataFromLDAP.Macro") For Each oUser in cUser Call myMacro.<TheNameOfYourSubInYourMacro>(oUser) 'I guess your sub takes in parameter your user Next
Regards,
Lionel
‎06-03-2013 11:29 AM
I need to set new User attribute "usorganization", I can read this data from LDAP, so I wrote a Java macro and add a MetaCommand to run it.
Have you other solution to set it?
However, to propagate this information, as adviced in one of the first answers, I tried this code:
set cUser = getRoot.getSelection("Select [User] Where [Name] Like '#giova#' And [Repository Access Mode] Not='4' ") 'set cUser = getRoot.User For Each oUser in cUser ' print oUser.GetProp("Name") oUser=MegaEnv.GetMacro("SetDataFromLDAP.Macro") Next
This is my result:
Script Debug : Error at Line 5 : Object doesn't support this property or method: 'oUser'
Thank you
Andrea G.
‎06-03-2013 09:59 AM - edited ‎06-03-2013 11:02 AM
Ciao Andrea,
I'm sorry but I really still do not understand why you create a metaCommand.
Then, can you give us a "more complete" code, because you tell us about an error on line 5... but your code example is only 4 lines 🙂
Furthermore, you cannot write
oUser = MegaEnv.GetMacro("MyMacro")
it does not make sense (since a user is a user, and not a macro 🙂
It should be :
oMacro = MegaEnv.GetMacro("MyMacro")
and then, eventually
Call oMacro.MySuperSub(myParameter1, myParameter2)
Maybe that was your question? You created a macro (not a metaCommand) and you want to call it from a script with each user in parameter? If that was your question, well you have the answer above, but to summarize:
Dim oMacro oMacro = MegaEnv.GetMacro("MyMacro") For each objUser in getRoot.User Call oMacro.MySuperSub(objUser) Next
Where mySuperSub would be a sub of the called macro "myMacro".
If that was not your question, please be more precise (and explain me the use of the metaCommand please ! 😉
Lionel
‎06-03-2013 08:43 AM
I have added in MetaClass User a new attribute (usorganization) and a MetaCommand that run a Java Macro, that getting data from LDAP sets this attribute.
I would like to recursively run it for all the users.
I tried:
set cUser = getRoot.User
For Each oUser in cUser
oUser=MegaEnv.GetMacro("MyMacro")
Next
but I get this error:
Script Debug : Error at Line 5 : Object doesn't support this property or method: 'oUser'
Thank you
Andrea G.
‎05-03-2013 04:48 PM
Hello Andrea,
can you explain us what you want to do ?
I do not understand what a metaCommand can be usefull for on the "User" metaclass.
I what you want to do is a mass treatment to set values for specific attributes of the user metaclass, you only need a simple script in the script editor. No metaCommand is needed. Your script should then look like :
For each objUser in getCollection("User") objUser.SetProp "<myAttribute>", "MyValue" Next
If this is not what you want to do, please be more precise 🙂
Lionel
‎05-03-2013 04:12 PM
Hi,
since you created a MetaCommand that set Attributes of the User MetaClass, you probably used a macro to do that ( a macro called from the MetaCommand).
i think the easiest way is to call this macro from your script:
oUser = MegaEnv.GetMacro("Your macro here").
By the way, you can use the function SetProp() to set the Attribute values you want on each user
Mohamed