Put two values in a field
Hello,
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,
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,
Hello!
1. Yes, it is possible. For example, like this:
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):
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:
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.
1. Yes, it is possible. For example, like this:
Code: Select all
fd.field('Libelle').value(fd.field('Type_Monant').value() +' ' + fd.field('Numero').value());
Code: Select all
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('.')));
3. Use the following code:
Code: Select all
//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());
}
fd.field('Type_Monant').change(assign);
-
- Information
-
Who is online
Users browsing this forum: No registered users and 8 guests