Upland OL User community

Replace property address fields if empty with main address fields

I have a template were there is an address box which appears in the envelope window and another text box which contains the property address on another part of the template, what I need to do is if the property address box fields are empty on some letters then put the address from the other box in it keeping both

my fields are as follows, address box in envelope window

Address in property box

Your assistance would be appreciated

Unless your Template is very complicated, it is simply a matter of checking the content of your Property field using a script.

This can be achieved in your Datamapper where you would fill the Property fields with those of the Addresses fields when those of Property are empty.

It can also be achieved in your Template when you are using script for your placeholder. You check if the fields for Property are not empty and if they are, you use the values from the Addresses ones.

Hi Jchamel,

I tried to do it in the datamapper using an action after the extraction but I could not get it to work using and tweaking the information that marten and Phil posted from these threads

I will have another look in the template script and see if I can work out how to do it in there

Can you anonymized your Datamapper and share it?
If not, send me a private message and I will give you my email address so you can share it with me and i will look into it.

There are multiple ways to do this. In Designer you could use a single script that calcs the length of your Add fields and based on the outcome copy the contents of the box holding the main address to the Add box. It could look something like this:

The box on the left is my Add box (I assigned an ID called ‘add’) and the box on the right holds my main address (has an ID called ‘main’). I’m using query(’#main’).html() to retrieve the contents of the main box.

When the address data is in a JSON data field it could look something like this:

More information on JSON data fields can be found here:

Hi Erik,
My main Address placeholder is called @Address@ in a text script and my other placeholder text script is called @PropAddr@

If the PropAddr is empty i want to put the details from the @address@ in the @PropAddr@ box

I amended your script to suit this but its not working, can you check it please in case i have made a mistake

var PropAddr = (record.fields.Property1 + record.fields.Property2 + record.fields.Property3 + record.fields.Property4 + record.fields.Property5)

if( !PropAddr.length) {
results.html( query(’#Address’).html() )

I will send you pm shortly

Hello @fergal,

Has what I sent you fixed your issue?

Hi Jchamel,

Yes, that worked perfectly :blush:

Thank you so much, for your help its very much appreciated.