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

Export field contents to text file

Explorer ,
Feb 11, 2023 Feb 11, 2023

Copy link to clipboard

Copied

Hi
I wonder if someone could please help me solve this problem
I have 4 fields
this.getField("LAST NAME").value; The text is YYYY
this.getField("NAME").value; The text is BBBB
this.getField("PRICE").value; The text is 10000
this.getField("TEXT").value;

In the TEXT field I inserted this function in the custom calculation script:

var s1=this.getField("LAST NAME").value;
var s2=this.getField("NAME").value;
var s3=this.getField("PRICE").value;
event.value=s1+" "+s2+" "+util.printf("€ "+"%,2.2f",s3);

In the TEXT field it appears:
YYYY BBBB € 10,000.00
Then I inserted this function in a button script to export the text contained in the TEXT field into a .txt file
var fields ="TEXT";
var endarray = [];
for(i=0 ; i <= fields.length -1 ; i++)
{console.println(fields);
arrayvalue = this.getField(fields).value.toString();
endarray = arrayvalue;
console.println(arrayvalue);
console.println("i-value: " + i);}
console.println(endarray);
var namestring = endarray[3] + " " + endarray[2] + " " + endarray[1];
console.println(namestring);
this.createDataObject({cName: "REPORT.txt", cValue: endarray});
this.exportDataObject({cName: "REPORT.txt", nLaunch: 1});

In the txt file the euro symbol € disappears

can anyone help me to solve this problem?
Thank you

TOPICS
JavaScript

Views

114

Translate

Translate

Report

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 ,
Feb 11, 2023 Feb 11, 2023

Copy link to clipboard

Copied

LATEST

Instead of setting the value directly in createDataObject, try using the setDataObjectContents method.

That will allow you to encode the string as "utf-8". See the examples given under that method in the API Reference.

Votes

Translate

Translate

Report

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