on 06-23-2011 1:25 AM
Dear Experts,
I have Query in SAP CLM :
I am in need to lock the delete function (Trash) for contract documents after they have been executed. After a user sets the contract document phase at "Executed," they should not be able to click the trash icon and delete that contract document record.
Thanks in advance.
Best Regards,
Iqbal
Hi Iqbal
What you need could be achieved through scripting.
Use the following logic:
1. Reach the contract document in the master agreement.
2. Verify the current phase to be executed using if condition
3. Use the method IapiDocumentLockManager.lockDocument(session,_contractDocument_ ) to lock the contract document (PS contractDocument is ContractDocumentIBeanIfc reference to current contract).
4. Save the agreement
Use Document Lifecycle Event as scripting context so that once you click on save, executed contract gets locked
Regards
Mudit Saini
Edited by: Mudit_UCB on Jun 23, 2011 8:52 AM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks Mudit for the quick response,
I am very new to CLM technical side, My requirement is that I want delete the trash icon(or can say in grey,inactive mode) when the contract documents has been excuted.
i have got some idea from your answer however I want to written the code ,
i am in need for the class like like the below mentioned. I am not expert in java
if (hasValue(current_phase))
{
// Lock the legal approval and workflow fields after draft phase
if (current_phase.equals("Draft"))
{
IapiDocumentLockManager.unlockField(sess
IapiDocumentLockManager.unlockField(session,
}
if (!(current_phase.equals("Draft")))
{
IapiDocumentLockManager.lockField(session, d
IapiDocumentLockManager.lockField(session
}
// If contract document phase is not Internal Approval
if ((current_phase.equals("Executed")))
{
Thanks in advance,
Iqbal,
if I am not wrong your are from GJU, Hisar... I too from GJU
Hi Iqbal,
I would suggest to execute your script as a PostPhase Change script. You can use the following logic in your script:
1) Check if the current_phase variables equals Executed. It will be a string comparison. current_phase is a system-set variable for PrePhase and PostPhase change events and denotes the current phase.
2) If the above condition is true then use the IapiDocumentLockManager APIs to lock the entire document.
You will need to import just the IapiDocumentLockManager APIs in your script.
Putting the script in PostPhase Change context will ensure that the script does not executes every time the contact document is saved.
Let us know if this works for you.
Thanks
Devesh
Hi Iqbal
Try the following script:
import com.frictionless.api.contracts.ContractIBeanHomeIfc;
import com.frictionless.api.contracts.ContractIBeanIfc;
import com.frictionless.api.doccommon.doc.contract.ContractDocumentIBeanHomeIfc;
import com.frictionless.api.doccommon.doc.contract.ContractDocumentIBeanIfc;
import com.frictionless.api.contracts.*;
import com.frictionless.api.ibean.IBeanHomeIfc;
import com.frictionless.api.ibean.IBeanHomeLocatorIfc;
import com.frictionless.api.common.platform.IapiSessionContextIfc;
import com.frictionless.api.common.platform.IapiDbHandleIfc;
import java.util.*;
import com.frictionless.api.doc.IapiDocumentLockManager;
contractDocumentList = doc.getContractDocuments();
for(Iterator iterator2 = contractDocumentList.iterator(); iterator2.hasNext();)
{
ContractDocumentIBeanIfc contractDocument = (ContractDocumentIBeanIfc)iterator2.next();
ContractDocumentHome = contractDocument.getIBeanHomeIfc();
if (contractDocument.getCurrentPhase().getDisplayName(session).equals("Executed")) // string compare to check executed
{
IapiDocumentLockManager.lockDocument(session,contractDocument ); // lock document
}
}
I would sggest some technical training in SAP BeanShell scripting. That would help you in getting started. There are technical training sessions provided by SAP. You can search the forum for more information.
Yes, I was in GJU.
Regards
Mudit Saini
Hi Mudit,
Thanks for the response. However its not working as I have tried in sciprt . My requirement is that trash icon shd be inactive or delete after the excuted.
Tha values I have taken:
Scripting Context: Document Lifecycle Event
Display Name:Contract Docs Locked
Script Version:1
Class: Master Agreement(1004) (I believe it shd be Contract documents 2002)
Instance Type: Any
Target: Saved (shd be Post Phase change)
However it not aloowing me to create duplicate or change these values.
Pls Help
Thanks
Iqbal
Hi Mudit,
we have already script for Contract Document and Post Phase Change.
I am not java expert, where to put the code for delete or inactive the trash icon in this programe, Pls Help
// Author: ABCD
// Class: Contract Document
// Context: Document Lifecycle Event
// Target: Post Phase Change
// Imports
import com.frictionless.api.doc.IapiDocumentLockManager;
import com.frictionless.api.common.types.ObjectReferenceIfc;
import com.frictionless.api.common.types.TypeFactory;
import com.frictionless.api.contracts.ContractIBeanIfc;
import com.frictionless.common.db.PersistentBo;
import com.frictionless.api.doc.collaboration.*;
import com.frictionless.api.common.log.Logger;
import java.math.BigDecimal;
import java.util.*;
import com.frictionless.api.doccommon.masterdata.*;
import com.frictionless.api.common.exception.*;
import com.frictionless.api.ibean.IBeanIfc;
import com.frictionless.api.ibean.IBeanHomeIfc;
import com.frictionless.api.contracts;
import com.frictionless.api.usermgmt.masterdata.*;
import com.frictionless.api.common.exception.*;
import com.frictionless.api.common.types.*;
import com.frictionless.api.ibean.*;
ApplicationException ae = new ApplicationException(session);
// Logger
logMsg = Logger.createLogMessage(session);
// Agreement Bean
agreeBean = doc.getParentIBean();
if (hasValue(current_phase))
{
// Lock the legal approval and workflow fields after draft phase
if (current_phase.equals("Draft"))
{
IapiDocumentLockManager.unlockField(session, doc, "CLAUSE_CHANGE");
IapiDocumentLockManager.unlockField(session, doc, "LEGAL_APPROVER");
}
if (!(current_phase.equals("Draft")))
{
IapiDocumentLockManager.lockField(session, doc, "CLAUSE_CHANGE");
IapiDocumentLockManager.lockField(session, doc, "LEGAL_APPROVER");
}
// If contract document phase is not Internal Approval
if ((current_phase.equals("Executed")))
{
agreeBean.getIBeanHomeIfc().upgradeToEdit(agreeBean);
collaboratorList = agreeBean.getCollaborators();
for (collabIter = collaboratorList.size(); collabIter > 0; collabIter--)
{
// Get the collaborator
collab = collaboratorList.get(collabIter-1);
name = collab.getDisplayName();
if (!collab.getCollaboratorRole().getDisplayName().equals("Owner") @and !collab.getRepresenting().getDisplayName().equals("Legal"))
{
collaboratorList.delete(collab);
}
}
agreeBean.getIBeanHomeIfc().save(agreeBean);
}
if ((current_phase.equals("Internal Approval")) @or current_phase.equals("Legal Approval"))
{
agreeBean.getIBeanHomeIfc().save(agreeBean);
agreeBean.getIBeanHomeIfc().downgradeToView(agreeBean);
}
}
Hi All -
If I understand the requirement correctly, you would like to prevent the deletion of contract documents once they are Executed. Is this correct?
If this is the requirement, thne scripting is not required. This can be accomplished via the security profile access rights; security profiles have a "delete" access right for Contract Documents. Simply disabling this access right should disable the delete (trash can) option for contract documents.
I hope this helps.
Rob
Hi Iqbal
Since you already have a script defined for master agreement save, system would not allow you to create another script for same document lifecycle management event. That is why you are facing issues
I would suggest putting my script at the top of the already existing code. You need not put the classes as they are already covered, just the code. Try and see if you face any errors
As far as Rob's suggestion is concerned, I think it would disable deletion of contract in all phases and not only in executed phase. You can give that a try and see whether it meets your requirement.
Regards
Mudit Saini
Dear Rob,
Thank you very Much for the response.
This is the requirement I am in Need
"Lock the delete function (Trash) for contract documents after they have been executed. After a user sets the contract document phase at "Executed," they(User) should not be able to click the trash icon and delete that contract document record. "
Pls let me know Path where I need to change the security Profiles I have not able to fine the Executed one.
Many Thanks
Iqbal
HI Mudit,
I have tried the script code on top as well as bottom how ever it is npot working.
//
contractDocumentList = doc.getContractDocuments();
for(Iterator iterator2 = contractDocumentList.iterator(); iterator2.hasNext();)
{
ContractDocumentIBeanIfc contractDocument = (ContractDocumentIBeanIfc)iterator2.next();
ContractDocumentHome = contractDocument.getIBeanHomeIfc();
if (contractDocument.getCurrentPhase().getDisplayName(session).equals("Executed")) // string compare to check executed
{
IapiDocumentLockManager.lockDocument(session,contractDocument ); // lock document
}
}
//
Pls suggest
Many Thanks
Iqbal
Hi Iqbal -
Security profiles are configured in setup on the system administration tab. There are 2 "rights" associated with Contract Documents that apply to this situation:
1) Delete
2) Administrative Delete
The first access right indicates whether or a not user can delete contract documents up until they are executed. The second access right provides for the delete option even after the contract documents are executed.
To address your use case, you should make sure that users have the Delete access right in one or more of their associated security profiles and make sure they do not have the Administrative Delete access right.
I hope this helps.
Regards,
Rob
Hi Mudit,
I am not getting any errors, I am putting the code suggested by you in our POST_PHASE_CHANGE script as mentioned.
After save this POST_PHASE_CHANGE. I am going Contract Management--> Agreements -> My Agreements and Contract documents . where we have some MA . when I click on any example MA-0062010. then Contract douemnts Tab.
I bring Tab Contract Documents "where we have some Executed Phase" in Edit Mode where we found the Trash ICON. and that Trash Icon is still active. we want this Trash Icon should be inactive.
Pls Suggest
Thanks
Iqbal.
Hi Iqbal
Let me clarify how post change script work:
In the master agreement lets say "MA-0062010" you have a contract lets say "Con_1001" in draft phase. When you move this contract to executed phase and click on Save (at the top of the "MA-0062010" toolbar ), post phase change script would trigger and Delete function would be disabled for "Con_1001"
So follow these steps:
1. click on example MA-006--2010.
2. Contract douemnts Tab.
3. Bring Tab Contract Documents "where you have some Executed Phase" in Edit Mode
4. click Save to make sure script is triggered
5. See whether Trash Icon is still active.
If this is not working for you still I would suggest try Rob's suggestion.
Regards
Mudit Saini
Edited by: Mudit_UCB on Jun 29, 2011 8:22 AM
Hi Rob,
I tried to set security profiles as per your suggestion in post. But entire row in Contract Documents tab is getting locked when its in EXECUTED phase. I just want to lock "Delete"(Trash Icon) option and the document should be editable.
Please suggest if I am missing something.
Thanks,
Saloni
Hi Saloni -
The system enforces certain restrictions once the contract document is executed. Unfortunately, you cannot change those behaviors. Out of curiosity, can you describe the requirement to edit an "executed" contract? Perhaps there is an alternative approach to address the requirement.
Thanks,
Rob
Hi Rob,
After I make the following settings in Security Profile,
Contract Generation-->Contract Document --> Create - Allow, View - Allow, Edit - Allow, Delete - Allow, Administrative Delete - Deny
Contract Generation-->Document Version --> Create - Allow, View - Allow, Edit - Allow, Delete - Allow, Administrative Delete - Allow
Below is the output,
All trash icon on Contract Document Tab are disabled.
Edit icon is enabled now for Executed phase contract document.
File upload is disabled on Contract Document UI.
Please guide me to disable trash icon for only EXECUTED phase documents and enable File upload on edit.
Thanks,
Saloni
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.