Hello,
Can any one please advise how I can split a full name like "Smith,John T" into "John Smith" without middle initial for a field that pre-populated by a web service. Note that the format will always be the same like last name comma firstname (without space) and middle initial. I tried different way but it does not seem to work as expected.
Thank you in advance,
Han Dao
Views
Replies
Total Likes
You can try the below code to get what you want..
//Get the Last name
var arrLastName = TextField1.rawValue.split(",");
var LastName = arrLastName[0];
//Get the First name
var arrFirstName = arrLastName[1].split(" ");
var FirstName = arrFirstName[0];
xfa.host.messageBox("" + FirstName + " " + LastName);
Thanks
Srini
Views
Replies
Total Likes
Hi Srini,
I try to place your code in the calculate event but it does not seem to work. Can you advise what event should I try to make it work.
Thanks,
Han Dao
Views
Replies
Total Likes
Try placing the code in the initialize event of the field which is prepopulated with the User Name data from Webservice.
And then change the "TextField1.rawValue" to "this.rawValue".
Thanks
Srini
Views
Replies
Total Likes
Hi Srini,
Well, actually the web service is not execute until user fill the empID and press enter for other fields such as full name to populate. So it seems like a litle tricky here that I need to split that full name after the above occurs. I tried to place the code in the initialize event but it does work.
Han
Views
Replies
Total Likes
Then the code might need to be placed in the event that executes Webservice code.
Probably after the code to execute webservice, place the above code and use the proper field name, that will hold the User Name value from the Webservice.
If you have using the Execute button to execute the webservice, then you might need to place the code in a separate button which is set to Regular type.
Set the visible property of the Execute button to "invisible".
In the click event of the Regular button make a call to Click event of Execute button.
Click event Script: Java Script
//Submit the Data to the Webservice
Page1.ExecWebService.execEvent("click");
//Then place the bove code to get the User name..
Thanks
Srini
Views
Replies
Total Likes
Views
Likes
Replies