HOW TO CREATE SUITELET ASSISTANT IN NETSUITE?

Creating a suitelet assistant involves the following steps:
Feel free to reach your NetSuite Solution Provider , TheSmilingCoders for proper netsuite implementationnetsuite consultation , netsuite customizationnetsuite Support,netsuite Training, contact us at:
Email : info@smilingcoders.com

1) Create the assistant.

2) Create steps.

3) Attach client script to validate data on page init, field change, save ( when user clicks on next or finish) or any other trigger function supported by client script.

4) Build pages for each step. (Get Function)

5) Set values for fields

6) Set up the action when user clicks on next, cancel, back or finish. (Post function)



1) Create the assistant

First step is to create assistant by using the api. You can provide name of the assistant under the api parameter.

var assist = nlapiCreateAssistant('SUITELET ASSISTANT);


2) Create steps.

Second step is to assign steps to the assistant. You must provide internal id and the name of the step. You can also declare if each step should be completed before proceeding to next one or can be completed randomly.

       var step1 = assist.addStep('customstep_step1', 'STEP1');

var step2 = assist.addStep('customstep_step2', 'STEP2');

var step3 = assist.addStep('customstep_step3', 'STEP3');


var step4 = assist.addStep('customstep_step4', 'STEP4');

assist.setOrdered(true);// true if each step needs to be completed one by one

3) Attach client script to validate data on page init, field change, save ( when user clicks on next or finish) or any other trigger function supported by client script.


assist.setScript('customscript_client_assist');

4) Build pages for each step.

Under the get function, get the currently selected step and build pages for each of them. You can add fields or sublist.

Note that suitelet assistant supports only inline editor type sublist.

if (request.getMethod() == 'GET')
   {



var step = assist.getCurrentStep();
 
if(step==null) //When the suitelet is first triggered, it can be null. So we set the current step as first                                //step
 
{
 
assist.setCurrentStep(assist.getStep("customstep_step1") );
 
step = assist.getCurrentStep();
 

}

 if (step.getName()=='customstep_step1')
     {
 

 
assist.addField('custpage_field1', 'text', 'Field1');
 
 assist.addField('custpage_field2', 'text', 'Field2').setDisplayType('disabled');
 
assist.addField('custpage_field3', 'select', 'Field3');


               var  sublist = assist.addSubList('custpage_sublist1', 'inlineeditor', 'SUBLIST1');
 
  sublist.addField('custpage_sub_fld1', 'checkbox','Include');
 
 sublist.addField('custpage_sub_fld_2','float','Quantity').setMandatory(true);
 
 
  sublist.addField('custpage_URL','url', 'URL').setDisplayType('disabled');
 
 
}

 

//similarly build pages for each step

5)  Set values for fields

                    assist.getField('custpage_field1').setDefaultValue(customer);
    
    assist.getField('custpage_field2').setDefaultValue(customer_id);
    

     assist.getField('custpage_field3').addSelectOption('id1' ,'first option', false);

                       assist.getField('custpage_field3').addSelectOption('id2' ,'second option', false);

    sublist.setLineItemValue('custpage_sub_fld1', 1, 'T');
           
            sublist.setLineItemValue('custpage_sub_fld_2', 1,10.5);
           
          sublist.setLineItemValue('custpage_URL','url', 1, "https://www.blogger.com");

response.writePage(assist);

6) Set up the action when user clicks on next, cancel, back or finish. (Post function)

else //post

if (request.getMethod() == 'POST')
   {



if (assist.getLastAction() == "next"||assist.getLastAction() == "back")
      {
assist.setCurrentStep( assist.getNextStep() );
 
assist.sendRedirect( response);

      }



          if (assist.getLastAction() == "finish")
      {
 assist.setFinished( "You have completed the Schedule Delivery Assistant." );
 
        //use   nlapiSetRedirectURL if you want to redirect user to any page
      }
 
if (assist.getLastAction() == "cancel")
      {
        
 
        //use   nlapiSetRedirectURL if you want to redirect user to any page

      }


}

Email : info@smilingcoders.com


Comments

Popular posts from this blog

USING CASE (IF AND ELSE) IN NETSUITE SAVED SEARCH- NETSUITE ACADEMY

Calling User Event Script from another User Event

Work Around the 1000 Row Limit Returned by Saved Searches in Netsuite