cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Leading zeros in Nintex form calculated field

Hi,

I'm trying to generate an unique ID inside Nintex forms using a calculated field. This number should be the current date with the item ID at the end.

I'm trying to generate this into a calculated field and display it on the form. With some runtime functions, getting the current date and put it in a specific format is not a problem. Adding the item ID at the end is easy too, but I want to have the ID with some leading zeros in front. Is there a function to achieve this?

This is what I already have: formatDate({Common:CurrentDate}, 'yyyyMMdd') + {ItemProperty:ID}

There should be a function like format({ItemProperty:ID}, '000000') but this doesn't work.

Any suggestions on this? By the way, this is in Nintex Forms Office 365.

Thanks in advance!

Labels: (1)
Tags (2)
Reply
6 Replies
Not applicable

Re: Leading zeros in Nintex form calculated field

Hi Davy,

Yes it is possible to add some leading zeros in front of it. You can use the property 'Value prefix' to add the value which you want in front. The property can be set in the Control Settings > General. Refer to screenshot below:

Answer.jpg

 

I hope this helps you achieve your requirement.

Thanks Davy

0 Kudos
Reply
Not applicable

Re: Leading zeros in Nintex form calculated field

Hi,

Thanks for your answer!

I think my question was a bit wrong formulated. Indeed the value prefix I can use to add zeros in front, but in fact I want to add zeros in front, depending on how many numbers my value has.

For example:

- value 12 should become 000012

- value 123 should become 000123

Any suggestions to achieve this?

Thanks!

0 Kudos
Reply
Not applicable

Re: Leading zeros in Nintex form calculated field

Hi Davy,

Yes it is achievable, but you would need to add some custom JavaScript to achieve your requirement. Please refer below for the steps:

1. Setup the calculated value properties as shown in the screenshot below

    Answer.jpg

      Set the formula to 'ID' token. Go to advanced, set 'Store Client ID in JavaScript variable' to true and set

      client id as 'ItemId'.

2.  Go to Formatting > CSS Class, and set it to 'updateValue', We will need to refer to this class to get the label to update the value in our      Custom JS script.

     Answer1.jpg

3. The, go to Form Settings > Custom JavaScript. Copy and paste the code snippet below:

   

     NWF.FormFiller.Events.RegisterAfterReady(function () {

             var oldValue = NWF$("#" + ItemId).val();

             var length = oldValue .length; 

             var appendStr= new Array(length + 1).join("0");

             NWF$(".updateValue label.nf-calculation-control").text(appendStr+ oldValue);

     });

    This snippet basically gets the value of the calculated field, counts the length of it and creates a string with character '0' based on the length. After we have that string, we append that to our old value, and update the label.

Hope this helps you achieve your requirement.

Thanks

Jeremy

0 Kudos
Reply
Not applicable

Re: Leading zeros in Nintex form calculated field

Great! You helped me a lot! :-) Thanks!

By the way, is there a possibility to use SPServices (jQuery Library for SharePoint Web Services - Home ) inside nintex forms too? This should be to be able to have cascading dropdown functionality.

My topic about this is here too (GetListItems (SPServices) inside Nintex form in O365 )

Thanks!

0 Kudos
Reply
Not applicable

Re: Leading zeros in Nintex form calculated field

Glad I could be of help to you.

0 Kudos
Reply
sverem
Nintex Newbie

Re: Leading zeros in Nintex form calculated field

How do you convert number values into text when the form is in display mode? My number 0-s are missing on display. I see blanks where I have to have 0 displayed.

0 Kudos
Reply