I want to display sequence numbers in a list displayed in catalog item.

KS18
Giga Guru

I want to display sequence numbers in a list displayed in catalog item.
Is it possible to automatically display sequence numbers when I add a list in variableSet?

 

find_real_file.png

6 REPLIES 6

Hitoshi Ozawa
Giga Sage
Giga Sage

Hi,

  1. Create a field to hold sequence number. Set type to "Single Line Text". In the example script below, I've named the field "num".
  2. Create an onChange script on the other field that is mandatory. In the script, I've made field "name" mandatory.
    find_real_file.png
  3. 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)

find_real_file.png

Step 2. Add 1 record

find_real_file.png

Step 3. Add another record

find_real_file.png

Thank you for sharing your response plan.
Even with this plan, if a row is deleted, it will still be skipped, correct?