on 12-26-2012 9:53 PM
Hi guys,
We have set up contracts, such that when they are created the system automatically adds a few collaborator groups by default.
We do NOT want to create a new document type for business reasons, but we want to add an extension field (checkbox) that will flag the deletion of specific groups from that collaborator's list. The script is to check that field each time it is saved and if it's checked it will delete "Group X" from that list.
I want to know if you guys think this is feasible and if it is, I have the following questions:
1) How do I access the collaborator's list for a contract?
2) How do I remove "Group X" from the Collaborators list?
I want to get ideas for actually writing the script and not so much ideas on the business logic.
Thank you,
Ok, thanks to Vikram I got the basic functionality working. I still want the system to show a confirmation pop up window before saving. How do we call a pop up confirmation window?
Here's the script as I implemented it.
confidential_check = doc.getExtensionField("confidential_check").get();
if(confidential_check){
collaborators = doc.getCollaborators();
if(collaborators.size() > 0){
collabIter = collaborators.iterator();
while (collabIter.hasNext()){
member = collabIter.next();
nametest = member.getDisplayName();
if(nametest.equals("Group X")){
collaborators.delete(member);
break;
}
}
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Vikram,
Since we can't add the check as pop-up, I'm trying to minimize "accidental" deletions of security groups with the script. So I want to have 2 scenarios:
1) User checks box and saves
2) User unchecks box and saves
So for the first one, I'm pretty much done. But for the second one, I don't know how to add a Group as a collaborator. Do you have sample code line to do that?
Thanks again!
Ivan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ivan,
There is an import template (Document Collaborators) that you can use to add or remove collaborators from documents if that can work for you. I've attached example import files. You do have to be careful to avoid adding duplicates, etc. I always test thoroughly with a small set before updating everything I want to update.
Rosemary
Hi Ivan,
Please find the below sample script code line for adding user group in the collaborator to MA :-
import com.sap.odp.api.usermgmt.masterdata.*;
supplierGroupHome=IBeanHomeLocator.lookup(session,GroupIBeanHomeIfc.sHOME_NAME);
// Get value for extension field "Collaborator Groups" from the bean
supplierGroupBean = supplierGroupHome.findGroup("Supplier_safety");
groupBeanReference = supplierGroupBean.getObjectReference();
// Create a new member to COLLABORATORS collection
collaboratorMember = collaboratorsCollection.create();
// Set the "USER_GROUP" field value of the newly created
// member to the above obtained group bean reference
collaboratorMember.getFieldMetadata("USER_GROUP").set(collaboratorMember,groupBeanReference); //Commented
collaboratorRoleHome = IBeanHomeLocator.lookup(session, CollaboratorRoleIBeanHomeIfc.sHOME_NAME);
collaboratorRoleBean = collaboratorRoleHome.findUniqueByName("Collaborator");
if(hasValue(collaboratorRoleBean))
{
collaboratorMember.setCollaboratorRole(collaboratorRoleBean.getObjectReference());
}
collaboratorMember.setSilent(true);
// Add the collection member supplier safety group to the collaborator collection
collaboratorsCollection.add(collaboratorMember);
//end of the code to add the collaborator
Hope the above mentioned code will help you.
Thanks,
Ankur Goyal
Message was edited by: Ankur Goyal
I envision this script to be like the following pseudo-code fragment:
isConfidential = getFieldValue(“Confidential”);
if(hasValue(isConfidential)) {
collabList = doc.getCollaborators();
if (collabList.contains(“Group X”)) { doc.deleteCollab(“Group X”);}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ivan,
You would have to first iterate through the collaborator collection.
collaborators = doc.getCollaborators();
iter = collaborators.iterator();
for (member : iter)
{
..
..
..
}
member.getPrincipal().getDisplayName() will return the name of the collaborators and collaborator group.
To delete a row in the collaborator collection, you could do something like this…
if(…) {
collaborators.delete(member);
break;
}
Hope this helps.
Regards,
Vikram
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.