Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 82002

Hide/Disable values in Optionset using javascript Form onLoad on custom entity

$
0
0

Hi CRM Community, 

ALERT!!! Novice java coder, but need help in disabling expired values in an optionset in Dynamics  CRM 365 online on a custom entity.

We have a custom entity named Mgmt Discount Reqs. This is used when reps need to request additional discounts on the opportunity which needs management approval before closing out the opportunity. Every management discount is created as a new record via a quick create form on the opportunity.

Optionset field name :  Reason for Request (schema name: aaa_reasonforrequest)

Values in the field have become outdated and need to be hidden so that these values cannot be selected but need to remain for historical data mining purposes.

Values to remove: 

Label: NB Spiff - 10% Comm Grps 1&2TBKs    Value: 811110003

Label: SL Spiff 3+ Months +5%   Value: 811110006

Label: NB Spiff - No Special Discount   Value: 811110001

Label: NB Spiff - Discount Requested   Value:  811110002

In the mgmt discount form editor - form properties,  I  added a form library named aaa_modifyreasonforrequest with the following script.

// JScript source code
function OnLoad() {
if (Xrm.Page.ui.getFormType() != 1) {
// Disable the field if the mgmt discount form is CREATE Mode
Xrm.Page.ui.controls.get("aaa_reasonforrequest").setDisabled(true);
}
else {
//If Create Form
Xrm.Page.getControl('aaa_reasonforrequest').removeOption(811110006);
}
}

I also added this to the event handlers on section: Control = Form / Function = OnLoad.  

Code above does not execute when testing the first value. Please help me understand what I am doing wrong. Let me know if you need more information to better understand.

Thanks in advance!


Viewing all articles
Browse latest Browse all 82002

Latest Images

Trending Articles



Latest Images