Put two values in a field


Posted by Eax - Oct 28 ’15 at 10:26


I want to made a form with a choice menu and two simple line text. My question is if it's possible to set two values on a field.

Second : in the other field, i need to put a number automatically when a new form is created.

Exemple :

I made a new form :




And when in "Type_Montant" I select "Avenant" for exemple, i want to put it automatically in my field "Libelle" : "Avenant 1"

The "1" is because i want to generate my field "Numero" a number 1 to 99 :

Best regards,










  • rostislav
    Member for: 6 years 7 months 4 days
    #1 by rostislav Oct 29 ’15 at 06:01


    1. Yes, it is possible. For example, like this:

    fd.field('Libelle').value(fd.field('Type_Monant').value() +' ' + fd.field('Numero').value());

    2. I'm not clear as to how you want to generate that number. If you simply want a random number from 1 to 99, here's a snippet for you(add it to the JS editor for the form in Forms Designer):

    function getRandomArbitrary(min, max) {
        return Math.random() * (max - min) + min;
    var rnd = getRandomArbitrary(1,100).toString();
    fd.field('Numero').value(rnd.substring(0, rnd.indexOf('.')));

    Note, that if you want an ID field, there is already one built in in every SharePoint list. But it is available only after the creation of a record, since that's when the ID is assigned.

    3. Use the following code:

    //in the case if Type_Monant is a choice field
    function assign () {
    	fd.field('Libelle').value(fd.field('Type_Monant').value() +' ' + fd.field('Numero').value());
    //in the case that Type_Monant is a lookup field
    function assign () {
    	fd.field('Libelle').value(fd.field('Type_Monant').control('getSelectedText') +' ' + fd.field('Numero').value());

    Note, that of course, you'll have to replace Internal Names as and if appropriate. An Internal Name of a field can be checked by clicking the field in Forms Designer and checking the grid on the right hand side.

  • Eax
    Member for: 6 years 1 month 11 days
    #2 by Eax Nov 9 ’15 at 09:15

    [#1]: Work great, thanks

Displaying 1 to 2 of 2 messages