cancel
Showing results for 
Search instead for 
Did you mean: 

Update standard collection(Collaborators in Project creation) from a custom extension collection

RatneshSisodiy1
Active Participant
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

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

RatneshSisodiy1
Active Participant
0 Kudos

Hi Vignesh,

Thanks for reply.

A little query.

Can you please tell me, should I use Document life cycle event for above scenario? if yes ,what should be target? saved or validated or anything else? sorry for basic question , I  am new to Sourcing ?

Thanks a lot.

Former Member
0 Kudos

Hi Ratnesh,

Yes, use Document life cycle event.

Use Validate as target.

Regards,

Vignesh

Former Member
0 Kudos

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

former_member207877
Active Participant
0 Kudos

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

Former Member
0 Kudos

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

former_member207877
Active Participant
0 Kudos

Krish,

In the IBeanHomeLocator you have used llokup instead of lookup.

Also please check all the imports

Raj

Former Member
0 Kudos

Hi Raj,

Sorry for the typo.

It was typing mistake at the time of  posting.

I have used correct wording and imported necessary things.

Thanks

Krish

former_member207877
Active Participant
0 Kudos

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

Former Member
0 Kudos

Hi Raj,

Thank You very much for your input.

I am able to add a collaborator to the Agreement.

Thanks

Krish

Answers (0)