Setting value on Checkbox

7.3a

On quoteitems summary page, when the user selects a product. if productid is a certain value a checkbox on the summary must be checked. I'm trying to do this using the client side API.

It doesn't work, the product submit method is breaking it.

jscript:ProdChanged();EntryForm.submit(); This happens onchange of product. Without it the screen will not fetch the list price for the selected product.
Because of this the when I try to set crm('quit_sale').val('Y'); it checks, but then the submit occurs and wipes it out. The check is not persisted through the refresh.

If I try to set a default value based on the product ID being said value it doesn't seem to work either. The checkbox is never checked. I can check it using the code above but every refresh unchecks it.

If tried this on the CreateScript:

var prodid=Values('quit_productid');if(prodid=='113'||prodid=='114'||prodid=='114'||prodid=='116'||prodid=='117'){DefaultValue='Y';ReadOnly=true;}

I've tried on changescript on the product selection

jscript : ProdChanged();
EntryForm.submit();
if (crm('quit_productid').value()) {
var prodid = crm('quit_productid').value();
if (prodid == '113' || prodid == '114' || prodid == '114' || prodid == '116' || prodid == '117') {
crm('quit_sale').val('Y');
}
}

This will check the box then the postback removes the check.

Any help is greatly appreciated.

  • 0

    Hi Bradd,

    Place the script in the Custom Content area of the screen that the checkbox is being applied.

    [code]

    crm.ready(function() {
    var pContextInfo = crm.getArg("Act",crm.url()); //check the screen is correct eg: New, Edit from Quote etc.
    crm.infomessage(pContextInfo); //send the ACT value to the screen to check
    if (pContextInfo == "") { //add the value(s) to the if statement for the code to check
    var prodid = crm.fields('quit_productid').value();
    if (prodid == '113' || prodid == '114' || prodid == '114' || prodid == '116' || prodid == '117') {

    $('input:checkbox[name=quit_sale]').attr('checked',true);
    }
    }
    });

    [/code]

    I haven't tested it (not sure where exactly you are referring too) - but check for the ACT codes then add the ACT code (or codes) into your first if statement.
    I am currently working on a similar project so this may save you some time by putting you in the right direction anyhow!
    I am not a gun at programming so more than likely this can be improved!

    Cheers Bradd.


    Kind Regards,


    Penny Vaskess