I want to display sequence numbers in a list displayed in catalog item.
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-01-2022 09:22 PM
6 REPLIES 6

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2022 01:39 AM
Hi,
- Create a field to hold sequence number. Set type to "Single Line Text". In the example script below, I've named the field "num".
- Create an onChange script on the other field that is mandatory. In the script, I've made field "name" mandatory.
- Create on Catalog Client Script in mrvs (not on the form but in the mrvs)
Client script
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var json = parent.g_form.getValue('rows_in_mrvs'); // get all rows in mrvs
var lastSeq = 0;
if (json) { // if rows exists, find the largest seq no
json = JSON.parse(json);
for (var i = 0; i < json.length; i++) {
var seq = parseInt(json[i].num);
if (seq > lastSeq) {
lastSeq = seq;
}
}
}
g_form.setValue('num', lastSeq + 1); // set sequence number
}
Execution result
Step1. initial entry (no record)
Step 2. Add 1 record
Step 3. Add another record
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2022 11:34 PM
Thank you for sharing your response plan.
Even with this plan, if a row is deleted, it will still be skipped, correct?