While Integrating NetSuite Sales Order I want to map only few items not all from Salesforce.
I am trying to do it using preSavePageFunction as shown below
function preSavePageFunction(options) {
for (var i = 0; i < options.data.length; i++) {
var order = options.data[i];
var filteredOpportunityLineItems = [];
for (var j = 0; j < order.OpportunityLineItems.length; j++) {
var item = order.OpportunityLineItems[j];
if (item.DoNotSync__c == 'false') {
filteredOpportunityLineItems.push(item);
}
}
order.OpportunityLineItems = filteredOpportunityLineItems;
}
return {
data: options.data,
errors: options.errors
};
}
But it is not working.
Can someone please help me here
-
Anil Anwane Are you trying to do the preSavePageFunction in a custom flow or are you using any of the flows in the Salesforce - NetSuite integration app?
0 -
Hi,
I have created a custom Standalone flow in Celigo for Salesforce to NetSuite Integration.
0 -
Hi Anil,
Thanks for the information. Since you are using a custom flow to perform this operation, I am moving this to the Troubleshoot custom flows topic for better visibility.
0 -
Don't use for loops for iterating arrays, but use forEach. And then use filter() to remove things you dont need:
options.data.forEach(order => {
order.OpportunityLineItems = order.OpportunityLineItems.filter(line => line.DoNotSync__c == 'false');
});0 -
Hi Bas Van,
I tried using For Each. I am getting same error as given below.
Extension result doesn't contain the same number of elements as the request object. Expected 1, got . Extension returned statusCode 200.
Can you please provide me if you have any such function used for removing few line items from SalesOrder.
Many thanks,
Anil
0 -
Anil Anwane can you send what the JSON input of your script is? Can't help much without that.
0 -
Hi Tyler Lamparter,
Please find the input JSON below.
{
"data": [
{
"Id": "Id",
"IsDeleted": "IsDeleted",
"IsPrivate": "IsPrivate",
"Name": "Name",
"Description": "Description",
"StageName": "StageName",
"Amount": "Amount",
"Probability": "Probability",
"ExpectedRevenue": "ExpectedRevenue",
"TotalOpportunityQuantity": "TotalOpportunityQuantity",
"CloseDate": "CloseDate",
"Type": "Type",
"NextStep": "NextStep",
"LeadSource": "LeadSource",
"IsClosed": "IsClosed",
"IsWon": "IsWon",
"ForecastCategory": "ForecastCategory",
"ForecastCategoryName": "ForecastCategoryName",
"HasOpportunityLineItem": "HasOpportunityLineItem",
"CreatedDate": "CreatedDate",
"LastModifiedDate": "LastModifiedDate",
"SystemModstamp": "SystemModstamp",
"LastActivityDate": "LastActivityDate",
"PushCount": "PushCount",
"LastStageChangeDate": "LastStageChangeDate",
"FiscalQuarter": "FiscalQuarter",
"FiscalYear": "FiscalYear",
"Fiscal": "Fiscal",
"ContactId": "ContactId",
"LastViewedDate": "LastViewedDate",
"LastReferencedDate": "LastReferencedDate",
"HasOpenActivity": "HasOpenActivity",
"HasOverdueTask": "HasOverdueTask",
"DeliveryInstallationStatus__c": "DeliveryInstallationStatus__c",
"TrackingNumber__c": "TrackingNumber__c",
"NetSuiteSalesOrder__c": "NetSuiteSalesOrder__c",
"CurrentGenerators__c": "CurrentGenerators__c",
"MainCompetitors__c": "MainCompetitors__c",
"Ammendment_Opportunity_Type__c": "Ammendment_Opportunity_Type__c",
"RA_Source_Document__c": "RA_Source_Document__c",
"Account": {
"Id": "Account.Id"
},
"OpportunityLineItems": [
{
"Id": "Id",
"SortOrder": "SortOrder",
"ProductCode": "ProductCode",
"Name": "Name",
"Quantity": "Quantity",
"TotalPrice": "TotalPrice",
"UnitPrice": "UnitPrice",
"ListPrice": "ListPrice",
"ServiceDate": "ServiceDate",
"Description": "Description",
"CreatedDate": "CreatedDate",
"LastModifiedDate": "LastModifiedDate",
"SystemModstamp": "SystemModstamp",
"IsDeleted": "IsDeleted",
"LastViewedDate": "LastViewedDate",
"LastReferencedDate": "LastReferencedDate",
"DoNotSync__c": "DoNotSync__c",
"End_Date__c": "End_Date__c",
"Start_Date__c": "Start_Date__c",
"Product2": {
"NetSuite_Item_ID__c": "Product2.NetSuite_Item_ID__c"
}
}
]
}
],
"_importId": "651125c1d6edd5374f92f456",
"_connectionId": "6504237d52cd84685a218ae3",
"_flowId": "650d5657fdc8375a68630ff6",
"settings": {
"integration": {},
"flowGrouping": {},
"flow": {},
"import": {},
"connection": {}
}
}0 -
Anil Anwane what is not working with your script? It's working fine for me. I tested on the below sample and the output was only 1 line and not 2.
{
"Id": "Id",
"IsDeleted": "IsDeleted",
"IsPrivate": "IsPrivate",
"Name": "Name",
"Description": "Description",
"StageName": "StageName",
"Amount": "Amount",
"Probability": "Probability",
"ExpectedRevenue": "ExpectedRevenue",
"TotalOpportunityQuantity": "TotalOpportunityQuantity",
"CloseDate": "CloseDate",
"Type": "Type",
"NextStep": "NextStep",
"LeadSource": "LeadSource",
"IsClosed": "IsClosed",
"IsWon": "IsWon",
"ForecastCategory": "ForecastCategory",
"ForecastCategoryName": "ForecastCategoryName",
"HasOpportunityLineItem": "HasOpportunityLineItem",
"CreatedDate": "CreatedDate",
"LastModifiedDate": "LastModifiedDate",
"SystemModstamp": "SystemModstamp",
"LastActivityDate": "LastActivityDate",
"PushCount": "PushCount",
"LastStageChangeDate": "LastStageChangeDate",
"FiscalQuarter": "FiscalQuarter",
"FiscalYear": "FiscalYear",
"Fiscal": "Fiscal",
"ContactId": "ContactId",
"LastViewedDate": "LastViewedDate",
"LastReferencedDate": "LastReferencedDate",
"HasOpenActivity": "HasOpenActivity",
"HasOverdueTask": "HasOverdueTask",
"DeliveryInstallationStatus__c": "DeliveryInstallationStatus__c",
"TrackingNumber__c": "TrackingNumber__c",
"NetSuiteSalesOrder__c": "NetSuiteSalesOrder__c",
"CurrentGenerators__c": "CurrentGenerators__c",
"MainCompetitors__c": "MainCompetitors__c",
"Ammendment_Opportunity_Type__c": "Ammendment_Opportunity_Type__c",
"RA_Source_Document__c": "RA_Source_Document__c",
"Account": {
"Id": "Account.Id"
},
"OpportunityLineItems": [
{
"Id": "Id",
"SortOrder": "SortOrder",
"ProductCode": "ProductCode",
"Name": "Name",
"Quantity": "Quantity",
"TotalPrice": "TotalPrice",
"UnitPrice": "UnitPrice",
"ListPrice": "ListPrice",
"ServiceDate": "ServiceDate",
"Description": "Description",
"CreatedDate": "CreatedDate",
"LastModifiedDate": "LastModifiedDate",
"SystemModstamp": "SystemModstamp",
"IsDeleted": "IsDeleted",
"LastViewedDate": "LastViewedDate",
"LastReferencedDate": "LastReferencedDate",
"DoNotSync__c": "false",
"End_Date__c": "End_Date__c",
"Start_Date__c": "Start_Date__c",
"Product2": {
"NetSuite_Item_ID__c": "Product2.NetSuite_Item_ID__c"
}
},
{
"Id": "Id",
"SortOrder": "SortOrder",
"ProductCode": "ProductCode",
"Name": "Name",
"Quantity": "Quantity",
"TotalPrice": "TotalPrice",
"UnitPrice": "UnitPrice",
"ListPrice": "ListPrice",
"ServiceDate": "ServiceDate",
"Description": "Description",
"CreatedDate": "CreatedDate",
"LastModifiedDate": "LastModifiedDate",
"SystemModstamp": "SystemModstamp",
"IsDeleted": "IsDeleted",
"LastViewedDate": "LastViewedDate",
"LastReferencedDate": "LastReferencedDate",
"DoNotSync__c": "true",
"End_Date__c": "End_Date__c",
"Start_Date__c": "Start_Date__c",
"Product2": {
"NetSuite_Item_ID__c": "Product2.NetSuite_Item_ID__c"
}
}
]
}0
Please sign in to leave a comment.
Comments
8 comments