Reputation: 1
i want to use an array that contains all the fields and it will be hidden and use for loop to do it.
Inside the CRM MS i don't know how.
function hideShowPicklist(executionContext) {
var RequiredField = GetAttributeValue(executionContext, "requiredtype");
var ProcessField = GetAttributeValue(executionContext, "processtypecode");
if (RequiredField == "0" && ProcessField == "4" || ProcessField == "5") {
// it will Show the fields and set them as Required
SetAttrsVisibility(executionContext, "name", ",", true);
SetAttrsVisibility(executionContext, "managername", ",", true);
SetAttrsVisibility(executionContext, "fordealexecution", ",", true);
SetAttrsVisibility(executionContext, "registrationaddress", ",", true);
}
}
I want the code to be very short by using array and for loop.
Upvotes: -1
Views: 50
Reputation: 7938
You are using a proprietary library I have no knowledge of and the precise workings of functions GetAttributeValue
and SetAttrsVisibility
is not fully clear, but I guess you are looking for a solution similar to this:
function hideShowPicklist(executionContext) {
const processType = GetAttributeValue(executionContext, "processtypecode");
const isRequired = (processType === "4" || processType === "5")
&& GetAttributeValue(executionContext, "requiredtype") === "0";
[
"name",
"managername",
"fordealexecution",
"registrationaddress"
]
.forEach(attributeName => {
SetAttrsVisibility(executionContext, attributeName, ",", isRequired);
});
}
Upvotes: 0