Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

If/else AND merge fields at the same time

Contributor ,
Oct 09, 2024 Oct 09, 2024

Todays call for help please

 

I have seperate fields for Installation Postcode, Installation City, Billing Postcode and Billing City.

I need to merge the installation postcode and city and pull that into a different field, BUT if there is something in the Billing Postcode and City, it needs to merge and pull those details instead.

 

I've worked out how to merge the fields and I can pull either the postcode or the city across, but I can't for the life of me work out how to get it to do everything at once!

 

These are the variables

var BillingPC = this.getField("Master.ACCOUNT_BILLINGPOSTALCODE").valueAsString;

var BillingCity = this.getField("Master.ACCOUNT_BILLINGCITY").valueAsString;

var InstalPC = this.getField("installation post code").valueAsString;

var InstalCity = this.getField("installation city").valueAsString;

 

Can anyone show me how to do this. Thank you

 

TOPICS
How to , JavaScript , PDF , PDF forms
573
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
1 ACCEPTED SOLUTION
Community Expert ,
Oct 09, 2024 Oct 09, 2024

Place this script as a calculation script in the field that hold the merged data:

 

var str1 = "";
var str2 = "";
var BillingPC = this.getField("Master.ACCOUNT_BILLINGPOSTALCODE");
var BillingCity = this.getField("Master.ACCOUNT_BILLINGCITY");
var InstalPC = this.getField("installation post code");
var InstalCity = this.getField("installation city");

if (BillingPC.value != BillingPC.defaultValue) {str1 = BillingPC.value;}
else {str1 = InstalPC.value;}
if (BillingCity.value != BillingCity.defaultValue) {str2 = BillingCity.value;}
else {str2 = InstalCity.value;}

event.target.value = str1 + " " + str2;

 


Acrobate du PDF, InDesigner et Photoshopographe

View solution in original post

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 09, 2024 Oct 09, 2024

Place this script as a calculation script in the field that hold the merged data:

 

var str1 = "";
var str2 = "";
var BillingPC = this.getField("Master.ACCOUNT_BILLINGPOSTALCODE");
var BillingCity = this.getField("Master.ACCOUNT_BILLINGCITY");
var InstalPC = this.getField("installation post code");
var InstalCity = this.getField("installation city");

if (BillingPC.value != BillingPC.defaultValue) {str1 = BillingPC.value;}
else {str1 = InstalPC.value;}
if (BillingCity.value != BillingCity.defaultValue) {str2 = BillingCity.value;}
else {str2 = InstalCity.value;}

event.target.value = str1 + " " + str2;

 


Acrobate du PDF, InDesigner et Photoshopographe
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Oct 09, 2024 Oct 09, 2024
LATEST

Perfect, thank you so much @JR Boulay 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines