You are viewing limited content. For full access, please sign in.

Question

Question

Can we format Field value in Forms

asked on November 22, 2016

Hi  

 

In Laserfiche forms I am capturing the Login user name token which is "FirstName Lastname".   In need the name to show "LastName, FirstName".   I tried the regex on advance section of the forms' field but it did not work. Regex is not able to capture part of the text.  The same regex works in workflow but did not work on forms.  I even used it to create a document name in repository on submission but still couldn't capture regex pattern value.  For example:  

I had the following regex:  \w+ (\w+)(,\s)(\w+) \w+

The value in the field was:  fname lname, fname lname      ( I used the token twice here and also  typed the name in field's default value without token)

I was expecting the name to show as     lname, fname

but it still shows    fname lname, fname lname

 

I was expecting regex to behave the same way LF form as workflow.   Is there a way to retrieve and format field values in Forms?

 

0 0

Replies

replied on November 23, 2016 Show version history

The regex in forms is for Validation purposes only which is why it is not providing the results you are looking for.

If you are in forms 10, you would have to use the calculation feature under the advance tab to create a formula to string this together the way you require. Such as you would in Excel using Left, Mid or Right to capture parts of the fields and Concatenate them back together.

0 0
replied on November 23, 2016

 

Thank you for clarifying the Regex in Forms Vs. workflow.  I have not played much with excel formula's except number calculations.  I will see if there are any sample I can find on your suggestion.   

 

It is, somewhat, mentioned Regex validation on the description of regex on the field but I wasn't clear about it.  

 

 

0 0
replied on November 23, 2016 Show version history

I had a look at this quickly but I think I may have found an issue with using the calculations in forms.

You said your username that you were capturing was "Firstname""space""Lastname", is this correct?

The formula is would have used would have looked like =CONCATENATE(RIGHT(Fieldname,FIND(" ",FieldName)),",",(LEFT(Fieldname,FIND(" ",FieldName)),to grab the  characters LEFT and RIGHT of the Field space in the field name and string them back together in opposite order with a comma between them, but the  FIND " " (space character) is not returning the correct value of the position of the space.

I have reported this to LF.

So unless you have a character such as a period "." or some other character other than a space to look for, this will not work for you at this time and so you would have to resort to JS to accomplish this.

It would use a similar strategy in JS but unfortunately that is not my specialty.

0 0
replied on November 23, 2016

Yes you are correct.  I basically wanted to convert fname lname to lname, fname   .

 

In my example I was using the fname lname twice to make the formating easier with regex (as it worked for me in WF).  The name would come from login forms log in user name.  The login is the same.

 

0 0
replied on November 28, 2016 Show version history

Hi FarZali

As the fix for finding a space in a field using the Advanced Calculations will not be released until v10.2, I've tried a little JS Coding to get to the same result. 

I'm new to JS coding so I'm sure there are better ways to do this, but it did work in my testing.

I have assigned a CSS Class to the Input field (EmpName) where the customer enters their name in the format "Joe Smith" and the output Field (NewEmpName) where the text is reordered to "Smith,Joe"

Hopefully this gives you something to work with.

$(document).change(function () {
       var name = $('.EmpName input').val();
       var namelen = name.length;
       var pos = name.search(" ");
       var lastname = name.slice(pos+1,namelen);
       var firstname = name.slice(0,pos);
       var newname = (lastname + "," + firstname);

$('.NewEmpName input').val(newname);
});

1 0
replied on November 29, 2016

Thanks Steve

 

Your script worked for me.  I did minor adjustment.    It only worked for me when I treated single field as input and out put.

$(document).change(function () {
       var name = $('.NewEmpName input').val();
       var namelen = name.length;
       var pos = name.search(" ");
       var lastname = name.slice(pos+1,namelen);
       var firstname = name.slice(0,pos);
       var newname = (lastname + "," + firstname);

$('.NewEmpName input').val(newname);
});

 

This is great I appreciate your help on this.

0 0
replied on November 29, 2016

One more comment on this... This is great if I type the name into the field, it change the FName and LName position immidiatly.   But, if the name comes from Logged in User Name variable the name shows FName LName.  I have to click in the field and put a space for the field to trigger the Java.    

0 0
replied on November 29, 2016 Show version history

Try changing the first line of the code from .change to .ready, shown below, as this will trigger the script to run as soon as the page is loaded

$(document).ready(function () {

1 0
replied on November 29, 2016

It worked just fine.   Thank you so much for the script and support.

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.