Use the below way to disable the fields on BPF and it won't require "header_process_" and it should work fine:
Xrm.Page.getAttribute("tk_typeofoffer").controls.forEach(function(control, index) { control.setDisabled(true); })
/Check if the control exist on the form
if (Xrm.Page.getControl(“header_process_parentcontactid”) != null) {
Xrm.Page.getControl(“header_process_parentcontactid”).setDisabled(true);
}
The same script you can use to apply to the header fields.
//Check if the control exist on the form
if (Xrm.Page.getControl(“header_leadsourcecode”) != null) {
Xrm.Page.getControl(“header_leadsourcecode”).setDisabled(true);
}
Below is a code snippet which will help you to filter a lookup:
function filterLookup() {
//Check if the control exist on the form
if (Xrm.Page.getControl(“header_process_parentcontactid”) != null)
// add the event handler for PreSearch Event
Xrm.Page.getControl(“header_process_parentcontactid”).addPreSearch(addFilter);
}
}
function addFilter() {
var accountId = null;
var accountLookup;
var fetchQuery;
try {
//Check if control exist on form
if (Xrm.Page.getControl(“header_process_parentaccountid”) != null && Xrm.Page.getControl(“header_process_parentaccountid”).getAttribute().getValue() != null) {
//Get Account lookup value
accountLookup = Xrm.Page.getControl(“header_process_parentaccountid”).getAttribute().getValue();
//Get the account id
accountId = accountLookup[0].id;
}
//Build fetch
if (accountId != null || accountId != undefined) {
fetchQuery = “<filter type=’and’>” +“<condition attribute=’statecode’ operator=’eq’ value=’0′ />” +
“<condition attribute=’parentcustomerid’ operator=’eq’ value='” + accountId + “‘ />” +“</filter>”;
//add custom filter
Xrm.Page.getControl(“header_process_parentcontactid”).addCustomFilter(fetchQuery);
}
}
catch (e) {
Xrm.Utility.alertDialog(“addFilter Error: ” + (e.description || e.message));
}
}
Get/Set Value
We need to use below method to get/set the value on the BPF fields.
Xrm.Page.getControl(“header_process_descriptions”).getAttribute().getValue();
Xrm.Page.getControl(“header_process_description”).getAttribute().setValue(“Hello World”);
If you want to write a script on the header fields then you can use below line of code for this.
Xrm.Page.getControl(“header_leadsourcecode”).getAttribute().setValue(parseInt(value));
No comments:
Post a Comment