You can use Custome JavaScript for this:
- Set JavaScript variable for the 2 dropdown controls. For ex ddl1 and ddl2
- Use the below code in the Custome JavaScript of the Form Settings
var ddlNumericalCode1 = NWF$("#" + ddl1);
ddlNumericalCode1.change(function()
{
if(ddlNumericalCode1.find("option:selected").text()!="1000" || ddlNumericalCode1.find("option:selected").text()!="2000" ddlNumericalCode1.find("option:selected").text()!="3000" || ddlNumericalCode1.find("option:selected").text()!="4000")
{
var ddlNumericalCode2 =NWF$('#' + ddl2 + ' option:contains(Please select a value...)');
var ddlNumericalCode2Value = ddlNumericalCode2.val();
ddlNumericalCode2.prop('selected','selected');
NWF$('#' + ddl2).parent().find('input').val(ddlNumericalCode2Value);
NWF.FormFiller.Functions.ProcessOnChange(ddlNumericalCode2);
}
}
Hi Chaitra
Thanks for your help! I tried the following but it didn't work. What could be wrong?
Note:
1. My ddl1 = CostCentre, ddl2=RegionalCode
2. I noticed you had a "||" missing from the condition and added it.
3. My first dropdown is a list lookup.
var ddlCostCentre = NWF$("#" + CostCentre);
ddlCostCentre.change(function()
{
if(ddlCostCentre.find("option:selected").text()!="2;#3750" || ddlCostCentre.find("option:selected").text()!="17;#3751" || CostCentre.find("option:selected").text()!="18;#3760" || ddlCostCentre.find("option:selected").text()!="27;#4250")
{
var ddlRegionalCode =NWF$('#' + RegionalCode + 'option:contains(Please select a value...)');
var ddlRegionalCodeValue = ddlRegionalCode.val();
ddlRegionalCode.prop('selected','selected');
NWF$('#' + RegionalCode).parent().find('input').val(ddlRegionalCodeValue);
NWF.FormFiller.Functions.ProcessOnChange(ddlRegionalCode);
}
}
In case of list lookup column can you confirm using the browser developer tool what the below code returns:
NWF$("#" + CostCentre).find("option:selected").text()
Also check is any errors occur on the code which you have shared(using browser developer tool)
NOTE: replace CostCentre.find("option:selected").text()!="18;#3760" with ddlCostCentre.find("option:selected").text()!="18;#3760" in your code
Please share your outcome.
Hi Chaitra,
Both CostCentre and RegionalCode are returning empty values in the developer tool. They're both list lookups, any issues with this?
but this works:
This works
NWF$(document).ready(function () {
var CostCentreDDL = NWF$('#' + CostCentre);
function setRegionalCodeLookupValue(RegionalCode, value) {
NWF$(NWF$('#' + RegionalCode).siblings('select')[0]).val(NWF.RuntimeFunctions.parseLookup(value, true));
NWF$('#' + RegionalCode).val(value);
}
CostCentreDDL.change(function () {
var CostCentreValue = CostCentreDDL.val();
var CostCentreParsedValue = NWF.RuntimeFunctions.parseLookup(CostCentreValue,true);
if (CostCentreParsedValue != "3750" && CostCentreParsedValue != "3751" && CostCentreParsedValue != "3760" && CostCentreParsedValue != "4250") {
setRegionalCodeLookupValue(RegionalCode, ';#**SelectValue**');
}
})
})
Anybody can assist for the following:
IF the TransferStatus is select / set to External
THEN reset CostCentre to its default (Select...)
*this should not cause an issue if the CostCentre is already set to Select... but in case is different then reset it.
function setRegionalCodeLookupValue(RegionalCode, value) {
NWF$(NWF$('#' + RegionalCode).siblings('select')[0]).val(NWF.RuntimeFunctions.parseLookup(value, true));
NWF$('#' + RegionalCode).val(value);
}
This part is exactly what I needed for my purposes. Thanks!