Home > Blockchain >  Netsuite - Check a box from a Saved Search button
Netsuite - Check a box from a Saved Search button

Time:01-24

Some progress made here thanks to answer from Suitestar.

Managed to make a suitelet which performs the task. However:

  1. Only works by putting an absolute item ID in the script itself. The var rec_ID to pull through the ID of the item from the search does not work. I get a 'Missing Argument' error.

  2. Opens a blank window and the saved search page defaults to a blanket item search. I just want a popup to say 'Approved' and for the search to stay the same.

  3. How do I pull through the field ID from the search as well?

Suite URL and code below:

<button onclick=window.open(/app/site/hosting/scriptlet.nl?script=602&deploy=1&rec_id=2958);>Approve

/**
* @NApiVersion 2.x
* @NScriptType Suitelet
* @NModuleScope SameAccount
*/

define (['N/record'], function (record) {
    function onRequest(scriptContext) {
        
        var rec_Id=scriptContext.request.parameters.rec_Id; //getting parameter

        var itemRecObj= record.load({ type: record.Type.INVENTORY_ITEM, id: '2958', isDynamic:true });

        itemRecObj.setValue({ fieldId: 'custitem_aamac_custom_approved', value: true });

        itemRecObj.save();
    }

return {
    
    onRequest: onRequest
};
    
    });

CodePudding user response:

You can write a backend logic in suitelet script for checking the check box.

  • Load the record with internal id of item
  • Use setValue with value "true" for check box fieldID .
  • And then save the record.
  • deploy the suitelet in release mode, copy the external url put it in button onclick function.as in screenshot you did.
  • pass the parameter using &rec_Id something like this in the last of url

https://tstdrv1911674.extforms.netsuite.com/app/site/hosting/scriptlet.nl?script=6030&deploy=1&compid=TSTDRV1911674&h=e3ac9c7644c25b4dded1&rec_Id=

and get the parameter in suitelet script using

var rec_Id=scriptContext.request.parameters.rec_Id; //getting parameter

var itemRecObj= record.load({ type: record.Type.INVENTORY_ITEM, id: rec_Id, isDynamic:true });

itemRecObj.setValue({ fieldId: 'checkboxfieldId', value: true });

itemRecObj.save();

  • Related