-1

This is my suitelet 2.0 and I want to create item fulfillment for selected items also shows the error message if the item, quantity, and lot number do not match with the sales order item, quantity, and lot number. else create item fulfillment. Please help! var form = serverWidget.createForm({ title: "Create Item Fulfillment" }); form.addSubmitButton({ label: 'Submit' });

          var soNumber = form.addField({
            id : 'custpage_so_number',
            type : serverWidget.FieldType.TEXT,
            label : 'Sales Order Number'
        });

        var sublist = form.addSublist({
            id: "item_sublist",
            type: serverWidget.SublistType.INLINEEDITOR,
            label: "Item"
          });
          sublist.addField({
            id: "itemname",
            type: serverWidget.FieldType.SELECT,
            label: "Item",
            source: "item"
          });
          sublist.addField({
            id: "lotnumber",
            type: serverWidget.FieldType.TEXT,
            label: "Lot/Heat Number"
          });
          sublist.addField({
            id: "quantity",
            type: serverWidget.FieldType.TEXT,
            label: "Quantity"
          });
    }
    catch(e)
    {
        log.debug("error in get",e);
    }

    context.response.writePage(form);

    }
    else if (context.request.method === 'POST') {

        try{
    log.debug("suitelet is posting")
      
        }catch(er)
        {
            log.debug("error in post method",er);
        }
        
    }
}

});

Sujith Kumar
  • 872
  • 6
  • 19
Maria S
  • 3
  • 3
  • Please, at least edit the post to make code well formatted – d.k Jun 02 '23 at 05:09
  • This looks like some copied code where you are hoping someone will do your job for you. Please take the time to understand enough of what you are tasked with that you can use this forum for helping you fix something -- this is not a fee labour site. – bknights Jun 05 '23 at 19:41

1 Answers1

0

Your code is very brief and does not demonstrate whether data is loading into the fields you have created in your Suitelet. Working with what you have shared, you will want to add another column that would allow a user to SELECT the item they want to fulfill.

Example - adding a clickable checkbox in your Suitelet:

    sublist.addField({ id: 'custpage_apply', label: 'Select Item to Fulfill', type: serverWidget.FieldType.CHECKBOX });

Next, you will want to read this new checkbox in your POST statement of the code; whereby you only attempt to fulfil an order when the checkbox is marked TRUE.

Example:

...GET code above....
    else if (context.request.method === 'POST') {

    //BEGIN: Create fulfillment object, link to sales/purchase order:
    var objRecord = record.transform({
        fromType: record.Type.SALES_ORDER,
        fromId: {id},
        toType: record.Type.ITEM_FULFILLMENT,
        isDynamic: false,
    });

    try{
        //Capture table line count
        var getCount = context.request.getLineCount('item_sublist');
        
        for (var i = 0; i < getCount; i++) {
            var isApply = context.request.getSublistValue({
                group: 'item_sublist',
                name: 'custpage_apply',
                line: i
            });

            if (isApply == 'T') {
     
                 //ADD CODE TO TRACK and MARK MATCHING ITEM TO FULFILL
                 
            }
        }
         
        record.save(objRecord);
        context.response.write('FULFILMENT NOW SAVED');

  
    }catch(er)
    {
        log.debug("error in post method",er);
        context.response.write('ERROR FOUND ' + er);

    }
    
}
Arif WB
  • 186
  • 1
  • 13