Tutorials
Opportunity closed won in salesforce -> create customer and SO in NetSuite
20 min
in this tutorial, learn how to automate the creation of customers and sales orders in netsuite when an opportunity is closed won in salesforce prerequisites before you begin, ensure the following connections are established connection between engini and nesuite learn how to connection between engini and salesforce learn how to add outbound message webhook to get started, add a trigger add a new activity and choose “outbound message webhook” trigger of salesforce click on the “to json\xml sample” button to paste sample json payload and click on the “next step” button example for a json payload { "?xml" { "@version" "1 0", "@encoding" "utf 8" }, "soapenv\ envelope" { "@xmlns\ soapenv" "http //schemas xmlsoap org/soap/envelope/", "@xmlns\ xsd" "http //www w3 org/2001/xmlschema", "@xmlns\ xsi" "http //www w3 org/2001/xmlschema instance", "soapenv\ body" { "notifications" { "@xmlns" "http //soap sforce com/2005/09/outbound", "organizationid" "00d8d000008cgkjeao", "actionid" "04k8d000000xzmhaao", "sessionid" { "@xsi\ nil" "true" }, "enterpriseurl" "https //engini2 dev ed develop my salesforce com/services/soap/c/58 0/00d8d000008cgkj", "partnerurl" "https //engini2 dev ed develop my salesforce com/services/soap/u/58 0/00d8d000008cgkj", "notification" { "id" "04l8d00000trpf0aah", "sobject" { "@xsi\ type" "sf\ opportunity", "@xmlns\ sf" "urn\ sobject enterprise soap sforce com", "sf\ id" "0068d00000jatxbaad" } } } } } } click on the icon on the right side of the url to copy the url set up an outbound message in salesforce with the copied url set up an flow in salesforce with the outbound message back in engini, click on the “next step” button get opportunity add the “get opportunity” action of salesforce to get all details of the opportunity object type choose from the drop down the opportunity option record id click on the empty field, and the tooltip will pop up showing the options of the values you can choose choose the “sd\ id” value, by following the path response body > soapenv\ envelope > notifications > notification > sobject > sf\ id get account add the “get account” action of salesforce to the account object type choose from the drop down the “account” option record id click on the empty field, and the tooltip will pop up showing the options of the values you can choose choose the “account id” from the “get opportunity” activity add if condition add the “if condition” action of engini to check whether a sale order has been established in netsuite or not when we set up a sale order in netsuite, we will populate the “netsuite salesorder id” field with the number of the set up sale order using the if activity, we check whether the value in the “netsuite salesorder id” field is populated or not, if so – it means that the sale order has been established and there is no need to continue the process if not – it means that the sale order has not been established and the process will continue click on “add conditions” button click on left the field to show the tooltip with all the options you can choose click on the dynamic content label choose the “netsuite salesorder id” field from the “get opportunity” activity select the “is not equal” (<>) condition click on the right to show the tooltip with all the options you can choose click on the functions label choose the “null()” function, which return null if yes if the condition is met, the workflow will terminate click on “next step” button to add a activity that will be carried out if the condition is met add “terminate workflow” activity choose the “fell by condition” status from the dropdown options if n o if the condition isn’t met, engini will not take any action and the workflow can proceed to the next step initialize variable now, let’s initialize a variable that will later hold the customer id of the customer in netsuite choose “initialize variable” action of engini name field click on the empty field and choose a name for the variable for example “customer” type field choose from the drop down the “integer” option click on the “next step” button add if condition add engini’s “if condition” activity to check if the customer exists in netsuite or not when we create a customer in netsuite, we will populate the “netsuite account id” field with the customer id using the if activity we check whether the value in the “netsuite order id” field is populated or not, if so – this means that the customer has been established and there is no need to establish a new customer if not – it means that the customer has not been established and you need to establish it, populate the field “netsuite account id” and only then continue the process click on “add conditions” button click on left the field to show the tooltip with all the options you can choose click on the dynamic content label choose the “netsuite account id” field from the “get account” activity select the “greater” (>) condition click on the right field and write ‘0’ if yes if the condition is met, the workflow will turn to execute the process within the if yes block click on “next step” button to add a activity that will be carried out if the condition is met choose “set variable” action of engini click on the drop down and choose the name you gave the variable you initialize click on the empty field next to the “value” and choose from the tool tip the “netsuite account id” field from the “get account” activity if no if the condition isn’t met, the workflow will turn to execute the process within the if no block create record click on “next step” button to add a activity that will be carried out if the condition is not met add “create record” activity of netsuite choose the “customer” object type from the dropdown menu click on the “add fields” button to fill the fields in the “customer” form on the left field, select from the drop down the field you want to populate in the table for this process choose the following fields companyname subsidiary>>id (when you encounter a field name with ‘>>’ between the words, it signifies that the field is of an object type, and in such cases, you should populate the value in right – in this case “id”) email click on the right field, and the tooltip will pop up showing the options of the values you can choose for the companyname field choose the “account name” value from the “get account” activity for the remaining fields, select the values that best align with your specific requirements set variable click on the “next step” button inside the “if no” block add “set variable” activity of engini click on the drop down and choose the name you gave the variable you initialize in this case “customer” click on the empty field next to the “value” and choose from the tool tip the “internal id” field from the “create customer” activity update record click on the “next step” button inside the “if no” block add “update record” activity of salesforce after creating the new customer in netsuite, we need to update the corresponding account record in salesforce with the “netsuite account id” for future reference object type choose from the drop down the “account” option record id click on the empty field, and the tooltip will pop up showing the options of the values you can choose choose the “account id” value from the “get account” activity click on the “add fields” button on the left field, select from the drop down the field you want to populate in the table for this process choose the “netsuite account id” field click on the right field, and the tooltip will pop up showing the options of the values you can choose for the “netsuite account id” field choose the “internal id” value, from the previous activity of “create customer” click on the “next step” button initialize objects array add the “initialize objects array” action of netsuite name click on the empty field and choose a name for the variable for example “object array” object element type choose from the drop down the “salesorder itemelement” option click on the “next step” button append item object to array add the “append item objects to array” action of netsuite variable click on the drop down and choose the name you gave the variable you initialize fields click on the “add fields” button to fill the fields you want to append on the left field, select from the drop down the field you want to populate in the table for this process choose the following fields item>>id (when you encounter a field name with ‘>>’ between the words, it signifies that the field is of an object type, and in such cases, you should populate the value in right – in this case “id”) rate click on the right field, and the tooltip will pop up showing the options of the values you can choose for those fields, select the values that best align with your specific requirements click on the “next step” button create sales order add a new activity and choose the “create record” action of netsuite object type choose from the drop down the “sales order” type fields click on the “add fields” button to fill the fields you want to create on the left field, select from the drop down the field you want to populate in the table for this process choose the following fields entity>>id trandate message custbody order type>>id custbody end user>>id item>>items\[] click on the right field, and the tooltip will pop up showing the options of the values you can choose for this process choose the following values for “entity>>id” field choose the “customer” value from the “initialize variavle” activity of engini for “trandate” field choose the “close date” value from the “get opportunity” activity for “custbody order type>>id” field write ‘1’ for “custbody end user>>id” field choose the “customer” value from the “initialize variavle” activity of engini for “item>>items\[]” field choose the “object array\[]” value from the “initialize objects array” activity click on the “next step” button update record add a new activity and choose the “update record” action of salesforce after creating the new sales order in netsuite, we need to update the corresponding opportunity record in salesforce with the “netsuite salesorder id” for future reference object type choose from the drop down the “opportunity” type record id click on the empty field, and the tooltip will pop up showing the options of the values you can choose choose the “opportunity id” value from the “get opportunity” activity fields click on the “add fields” button on the left field, select from the drop down the field you want to populate in the table for this process choose the “netsuite salesorder id” field click on the right field, and the tooltip will pop up showing the options of the values you can choose for the “netsuite salesorder id” field choose the “internal id” value, from the previous activity of “create sales order”