- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2024 05:58 AM
Hi All,
I have created record producer mapping custom table fields. I have some integer fields in custom table. But, in Record producer variable type there is no integer option. Since, i selected single line text.
Can someone help me how to set integer validation for multiple variables at a time.
Thanks,
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2024 07:18 PM
You can modify the code something like below:
function onSubmit() {
var variableNames = ['variable_name1', 'variable_name2', 'variable_name3'];
for (var i = 0; i < variableNames.length; i++) {
var inputValue = g_form.getValue(variableNames[i]);
var intValue = parseInt(inputValue);
if (isNaN(intValue)) {
alert('Please enter a valid integer value for ' + variableNames[i] + '.');
return false; // Prevent submission
}
}
// Proceed with submission
return true;
}
Please Mark ✅Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2024 06:57 AM
I think there isn't a direct "integer" variable type in record producers, you can still achieve integer validation using scripting.
You can attach a client script to the record producer variables and use JavaScript functions like parseInt() or regular expressions to ensure that the input is a valid integer.
basic example of how you might validate an input field as an integer using client-side:
function onSubmit() {
var inputValue = g_form.getValue('variable_name'); // Replace 'variable_name' with the actual variable name
var intValue = parseInt(inputValue);
if (isNaN(intValue)) {
alert('Please enter a valid integer value.');
return false; // Prevent submission
}
// Proceed with submission
return true;
}
Please Mark ✅Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2024 10:07 AM
Hi Maddy Sunil,
Thanks for your reply. This will apply for a single variable. I want this to apply for multiple variables. Can you please modify code according and share. It will be more helpful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2024 07:18 PM
You can modify the code something like below:
function onSubmit() {
var variableNames = ['variable_name1', 'variable_name2', 'variable_name3'];
for (var i = 0; i < variableNames.length; i++) {
var inputValue = g_form.getValue(variableNames[i]);
var intValue = parseInt(inputValue);
if (isNaN(intValue)) {
alert('Please enter a valid integer value for ' + variableNames[i] + '.');
return false; // Prevent submission
}
}
// Proceed with submission
return true;
}
Please Mark ✅Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2024 12:16 AM
Hi Maddysunil,
Its worked after submitimg what ever entered other than integer it removed value form that fields. But, it should not allow to submit the form. Its allowed.