isNewRecord doesn't work on catalog forms?

e_wilber
Tera Guru

The below doesn't appear to work on any of my catalog items. My alert is always caught indicating that it doesn't see my new form loads as a new form. Is there a different way to check for a new record on a catalog item?

function onLoad() {

    //Type appropriate comment here, and begin script below

if (g_form.isNewRecord()) {

    g_form.setValue('qty', '1');

}

else {

alert('caught here');

}

7 REPLIES 7

Jaspal Singh
Mega Patron
Mega Patron

Hi Eric,



All seems to be perfect as far as script is concerned. Check if UI Type for Client script is set to Both.



Also, you below snippet with added alerts



function onLoad() {


    //Type appropriate comment here, and begin script below


if (g_form.isNewRecord()) {


alert('Setting quantity as 1');


    g_form.setValue('qty', '1');


}


else {


alert('caught here');


}


Hi Jaspal,



The UI type is set to All. I added the alert inside but the only alert caught is the one saying it isn't   caught as a new record. When I remove the set QTY from within those brackets, it works.



I just can't get it to detect that it is a new record.


Could you confirm the table the Client script is working on.


The function returns null instead of true/false on a catalog item.



What's the ultimate goal here?   Could you do something like if qty = null set it?