on 10-30-2013 9:39 AM
Hi Experts,
I would like to explain the scenario as below.
At the time of creating or modify a project in Sourcing, We have a custom tab. This tab is used to add some users and their some attributes. Now I click on standard SAVE button(on top level, common to all Header, Schedule..tabs) of the project, then all the users added in custom tab should get populated into COLLABORATORS section in HEADER tab of the project.
I am new to Sourcing. As per my understanding I should create a document life cycle script. Please let me know the approach and code(if possible) for how to read the custom extension collection and how to update the collaborators collection section.
Please help asap as it's a bit urgent.
Thanks,
Ratnesh
Hi Ratnesh,
Refer to the below link which will help you in building your script.
http://scn.sap.com/thread/3285159
In this link, you will get to know how we can delete a collaborator from the collaborator list by using delete() function.
Use create() and add() functions, in order to add the collaborator which you want to add.
Logic to write the script is
-get the collaborator which you want to add from the custom tab.
-get the collborators list in the document collaboratorsCollection = doc.getCollaborators();
-use create() function to create the row
-set values for name, role etc by setPrincipal(x), setCollaboratorRole(y)
-then use add(), to add that created row.
I hope this will solve your problem.
Regards,
Vignesh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Vignesh,
We are having similar kind of requirement.
I am trying to add a collaborator(user/group) to an agreement through script.
I am using the method doc.setPrincipal(objectreference), to set principal value.
What should I have to pass as object reference to this method ?
Can you please provide some guidance.
Thanks
Krish
Hello Krish,
You can set the collaborator as below
//getting the collaborators in Document
collabCollec= doc.getCollaborators();
//creating a Bean in Collaborator
newCollaboratorMember= collabCollec.create();
//Here get the Object reference for the respective User/group and then setting as below
newCollaboratorMember.setPrincipal(userBeanRef);
//Here get the Object reference for the respective Role and then setting as below
newCollaboratorMember.setCollaboratorRole(roleObjRef);
//Adding the Bean to Collaborators
collabCollec.add(newCollaboratorMember);
Object Reference for the user by creating user home and then getting the respective Bean and then getting Object Reference for the user as below
userHome=IBeanHomeLocator.lookup(session,NewUserAccountIBeanHomeIfc.sHOME_NAME);
userBean=userHome.findUniqueByEmail("user email Id");
(many find options will be available in User Home)
userBeanRef=userBean.getObjectReference();
Regards,
Raj
Hi Raj,
Thank You for your reply.
I am trying to see all values in the logs then I would like to add to collaborator collection.
I can see the Principal name(object reference ) in the logs by following your suggestion.
When I tried to see collaborator role(obj reference) in the logs by using the following code, I don't see it.
collaboratorRoleHome=IBeanHomeLocator.llokup(session,CollaboratorRoleIBeanHomeIfc.sHOME_NAME);
collaboratorRoleBean = collaboratorRoleHome.findUniqueByName("Collaborator");
collaboratorRoleRef = collaboratorRoleBean.getObjectReference();
Can you please correct me, if I am doing anything wrong.
Thanks
Krish
Hello Krish,
I have used the same and for me its working fine.
import com.sap.odp.api.ibean.IBeanHomeLocator;
import com.sap.odp.api.doc.collaboration.CollaboratorRoleIBeanHomeIfc;
import com.sap.odp.api.common.log.Logger;
import com.sap.odp.api.common.exception.*;
collaboratorRoleHome=IBeanHomeLocator.lookup(session,CollaboratorRoleIBeanHomeIfc.sHOME_NAME);
collaboratorRoleBean = collaboratorRoleHome.findUniqueByName("Collaborator");
collaboratorRoleRef = collaboratorRoleBean.getObjectReference();
logMessage("collaboratorRoleHome is: "+collaboratorRoleHome+ " collaboratorRoleBean is : " +collaboratorRoleBean+ " collaboratorRoleRef is : " +collaboratorRoleRef, 0);
See the logs screen below
Regards,
Raj
User | Count |
---|---|
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.