Hi all,
I'm currently working on a Marketing form that, on submission, should populate a lead and a contact form with the information included in the form. On our original Sales form, we have a Multi Select Option Set that gives the user option of various currencies (GBP, EUR, USD etc) to buy and to sell. However, our Marketing form required an Option Set with a smaller amount of currencies available, written in long form (Pound Sterling, Euros, US Dollars etc). I have therefore created new fields for this purpose, but I need to be able to find a way to map these fields to each other. For instance, should a user select Pound Sterling, the original field should be populated with GBP. I've written the following piece of JavaScript, but it doesn't seem to be working. Can anyone see what the problem is with my code/have any suggestions as to how this can be solved?
function setCurrencySell(executionContext) {
const formContext = executionContext.getFormContext();
//get client type
// corporate = 126670000
// private = 126670001
const clientType = formContext.getAttribute("new_clienttype").getValue();
if (clientType == 126670001) {
const currencyYouHave = Xrm.Page.getAttribute("new_CurrencyYouHave").getValue();
switch (currencyYouHave) {
case 126670000:
formContext.getAttribute("new_currencySell").setValue("126670000");
break;
case 126670001:
formContext.getAttribute("new_currencySell").setValue("126670002");
break;
case 126670002:
formContext.getAttribute("new_currencySell").setValue("126670001");
break;
case 126670003:
formContext.getAttribute("new_currencySell").setValue("126670010");
break;
case 126670004:
formContext.getAttribute("new_currencySell").setValue("126670091");
break;
case 126670005:
formContext.getAttribute("new_currencySell").setValue("126670076");
break;
case 126670006:
formContext.getAttribute("new_currencySell").setValue("126670139");
break;
case 126670007:
formContext.getAttribute("new_currencySell").setValue("126670118");
break;
case 126670008:
formContext.getAttribute("new_currencySell").setValue("126670163");
break;
case 126670009:
formContext.getAttribute("new_currencySell").setValue("126670130");
break;
case 126670010:
formContext.getAttribute("new_currencySell").setValue("126670104");
break;
case 126670011:
formContext.getAttribute("new_currencySell").setValue("126670083");
break;
case 126670012:
formContext.getAttribute("new_currencySell").setValue("126670038");
break;
case 126670013:
formContext.getAttribute("new_currencySell").setValue("126670125");
break;
case 126670014:
formContext.getAttribute("new_currencySell").setValue("126670040");
break;
case 126670015:
formContext.getAttribute("new_currencySell").setValue("126670096");
break;
case 126670016:
formContext.getAttribute("new_currencySell").setValue("126670115");
break;
case 126670017:
formContext.getAttribute("new_currencySell").setValue("126670056");
break;
case 126670018:
formContext.getAttribute("new_currencySell").setValue("126670082");
break;
case 126670019:
formContext.getAttribute("new_currencySell").setValue("126670111");
break;
case 126670020:
formContext.getAttribute("new_currencySell").setValue("126670134");
break;
case 126670020:
formContext.getAttribute("new_currencySell").setValue("");
break;
}
}
}
Many thanks,
Emily