@If to set field value - Code included

I have a form that contains three fields:AcqusitionName,AcqName and AName.

If the AcquisitionName field is empty, then AName=AcqName.

If the AcquisitionName field is not empty, then AName=AcqusitionName.

I have used the following @If in the default value of the AName field:

@If(AcquisitionName=“”; AcqName; AcquisitionName)

If the AcquisitionName field is not empty, then the AName field is set properly, however, if it is empty, then the AName field should be set to the value in AcqName - but it is not.

Is there something wrong with this formula? Any ideas or suggestions would be greatly appreciated.

Thanks in advance.

Subject: @If to set field value - Code included

is AcquisitionName field available in document or this is a new document.probabably in addition to checking empty value if you also check avalaibility of AcquisitionName field by using@If(AcquisitionName=“”|!@IsAvailable(AcquisitionName); AcqName; AcquisitionName)

This might work

Regards

Manu

Subject: RE: @If to set field value - Code included

There are two options available to the user - if the first option is selected, the AcquisitionName field is set, which in turn sets the AName field.

If the user selects the second option, the AcqName field is set (AcquisitionName is empty). The AName field should then be set to AcqName, but this is the part that is not working. I am not getting any errors.

I also tried the code that you supplied above, but that didn’t work either.

Thanks for the help - any other ideas?

Subject: RE: @If to set field value - Code included

In your initial post, you said that the formula was in the default value formula, suggesting that it’s an editable field which won’t change as other fields do. Did you mistype?

Subject: RE: @If to set field value - Code included

Correct - it wasn’t a mistype - the formula is in the default value of the AName field.

Once the value is set it should not change. Should this formula be placed elsewhere?

Subject: solution used

I removed the @If and placed the following javascript in the onLoad of the form:

document.forms[0].AcqName.value = parent.Menu.document.forms[0].AName.options[parent.Menu.document.forms[0].AName.selectedIndex].text;

if (document.forms[0].AcqName.value == “”)

{

document.forms[0].AName.value = document.forms[0].AcqName.value

}

else

{

document.forms[0].AName.value = document.forms[0].AcquisitionName.value

}

This works like a charm! Thanks for all of the help!