Jira Code: ME-202
An Opportunity Email template is created in CRM. An Object Workflow to sent email notification with opportunity Id is set in CRM to trigger a Scheduled script in NetSuite. When an opportunity is created/edited, it triggers the workflow and sends an email notification which is captured by the email plugin set in NetSuite. The email plugin then uses a Suitelet to call the Scheduled script. Once the Suitelet call the Scheduled Script, it runs the script to create/edit customers, contacts and products of the corresponding opportunity.
1. Sync customers to NetSuite when an opportunity is created/edited.
Oracle REST APIs in Oracle Sales Cloud to fetch the opportunities from Oracle Engagement Cloud. From the fetched opportunities we perform the customer update for the opportunities. We use opportunity TargetPartyId to fetch the corresponding customer. The PartyId of customer available in the CRM is Map to NetSuite customer PartyId. Customer PartyId is placed in a custom Field CRM Partyid in NetSuite.
We are using the NetSuite customer CRM Partyid and CRM customer PartyId to match the customer in CRM to customer in NetSuite. If customer is present in NetSuite for the corresponding customer PartyId in CRM, it loads the customer and updates customer details if any. In the else part, if the customer is not present, creates a customer with the fetched data and PartyId is set to external id and CRM Partyid Field in NetSuite.
2. Sync contacts to NetSuite when an opportunity is created/edited.
From the fetched opportunities we perform the contacts update for the opportunities. We use opportunity TargetPartyId to fetch the corresponding contacts. The PartyId of contacts available in the CRM is map to NetSuite contacts PartyId. Contacts PartyId is placed in a custom field CRM Partyid in NetSuite.
We are using the NetSuite contact CRM Partyid and CRM contacts PartyId to match the contact in CRM to contacts in NetSuite. If contact is present in NetSuite for the corresponding contact PartyId in CRM, it loads the contact and updates contact details if any. In the else part, if contact is not present, creates contact with the fetched data and PartyId is set to external id and CRM Partyid field in NetSuite.
3. Sync products to NetSuite when an opportunity is created/edited.
Oracle REST APIs in Oracle Sales Cloud to fetch the opportunities from Oracle Engagement Cloud. From the fetched opportunities we perform the item update for the opportunities. We use opportunity InventoryItemId to fetch the corresponding products. The InventoryItemId of products available in the CRM is map to NetSuite customer InventoryItemId. Product InventoryItemId is placed in a custom field CRM Partyid in NetSuite.
We are using the NetSuite item CRM InventoryItemId and CRM product InventoryItemId to match the product in CRM to items in NetSuite. If an item is present in NetSuite for the corresponding product InventoryItemId in CRM, it loads the item and updates item details if any. In the else part, if an item is not present, creates an item with the fetched data and InventoryItemId is set to external id and CRM Partyid field in NetSuite.
+/**
* @NApiVersion 2.x
* @NScriptType ScheduledScript
*/
define(['N/file', 'N/http', 'N/https', 'N/record', 'N/runtime', 'N/search', 'N/task'],
function(file, http, https, record, runtime, search,task) {
var auth_header="Basic aW1wX3VzZXI6bWdsbUA0NTY=";
var header_Url="https://eheg-test.fa.em2.oraclecloud.com/crmRestApi/resources/11.13.18.05";
var customers = {};
var contacts = {};
var products = {};
var item_Objdetails = [];
var STATE_MAP = {};
var newProduct;
var Cust_entityid;
function execute( context ) {
try{
var Cust_response=[];
var Cont_response=[];
var OppProd_response =[];
var opp_Items={};
opp_Items.OptyId=runtime.getCurrentScript().getParameter("custscript__optyid");
opp_Items.OptyNumber=runtime.getCurrentScript().getParameter("custscript__optynumber");
opp_Items.Targetid=runtime.getCurrentScript().getParameter("custscript__targetid");
log.debug("opp_Items",opp_Items);
Cust_response.push(JSON.parse(https.get({
url: 'https://eheg.fa.em2.oraclecloud.com/crmRestApi/resources/11.13.18.05/accounts?q=PartyId=' +opp_Items.Targetid+ '',
headers: {
authorization: auth_header,
accept: 'application/json'
}
}).body));
Cont_response.push(JSON.parse(https.get({
url: 'https://eheg.fa.em2.oraclecloud.com/crmRestApi/resources/11.13.18.05/contacts?q=AccountPartyId=' +opp_Items.Targetid+ '',
headers: {
authorization: auth_header,
accept: 'application/json'
}
}).body));
OppProd_response.push(JSON.parse(https.get({
url: 'https://eheg.fa.em2.oraclecloud.com/crmRestApi/resources/11.13.18.05/opportunities/'+opp_Items.OptyNumber+'/child/ChildRevenue',
headers: {
authorization: auth_header,
accept: 'application/json'
}
}).body));
/*To load custom record values to object item_0bj*/
var customrecord_jj_crm_prodyct_valuesSearchObj = search.create({
type: "customrecord_jj_crm_prodyct_values",
columns: [{
name: 'custrecord_jj_crm_name',
},
{
name: 'custrecord_jj_crm_category',
},
{
name: 'custrecord_jj_crm_value',
}
],
});
customrecord_jj_crm_prodyct_valuesSearchObj.run().each(function(result) {
var item_0bj = {};
item_0bj.name =result.getValue({
name: 'custrecord_jj_crm_name'
});
item_0bj.category = result.getText({
name: 'custrecord_jj_crm_category'
});
item_0bj.value =result.getValue({
name: 'custrecord_jj_crm_value'
});
item_Objdetails.push(item_0bj);
return true;
});
for(var i=0;i<Cust_response.length;i++){
for(var j=0;j<Cust_response[i].items.length;j++){
CE_customer(Cust_response[i].items[j],"true");
}
}
for(var i=0;i<Cont_response.length;i++){
for(var j=0;j<Cont_response[i].items.length;j++){
CE_Contacts(Cont_response[i].items[j]);
}
}
for(var i=0;i<OppProd_response.length;i++){
for(var j=0;j<OppProd_response[i].items.length;j++){
createdit_Products(OppProd_response[i].items[j]);
}
}
var pendingId=findPending();
if (pendingId != false) {
var pendingFile = file.load({
id: pendingId
});
var pendingContent = pendingFile.getContents();
var pendingContent = JSON.parse(pendingContent);
log.debug("pendingContent", pendingContent);
scheduleanother(pendingContent.custscript__optyid,pendingContent.custscript__optynumber,pendingContent.custscript__targetid);
file.delete({ id: pendingId });
}
}
catch(error){
log.debug("Error@Script Email Capture")
}
};
return {
execute : execute
};
/*Function to Create and Edit Customers */
function CE_customer(Cust_contents, parent_flag) {
try{
STATE_MAP = {
"": "",
"Andaman & Nicobar Islands": "35-AN",
"Andhra Pradesh": "37-AD",
"Arunachal Pradesh": "12-AR",
"Assam": "18-AS",
"Bihar": "10-BR",
"Chandigarh": "04-CH",
"Chhattisgarh": "22-CG",
"Dadra & Nagar Haveli": "26-DN",
"Daman & Diu": "25-DD",
"Delhi": "07-DL",
"Goa": "30-GA",
"Gujarat": "24-GJ",
"Haryana": "06-HR",
"Himachal Pradesh": "02-HP",
"Jammu & Kashmir": "01-JK",
"Jharkhand": "20-JH",
"Karnataka": "29-KA",
"Kerala": "32-KL",
"Lakshdweep": "31-LD",
"Madhya Pradesh": "23-MP",
"Maharashtra": "27-MH",
"Manipur": "14-MN",
"Meghalaya": "17-ML",
"Mizoram": "15-MZ",
"Nagaland": "13-NL",
"Odisha": "21-OD",
"Other Countries": "99-OC",
"Other Territory": "97-OT",
"Puducherry": "34-PY",
"Punjab": "03-PB",
"Rajasthan": "08-RJ",
"Sikkim": "11-SK",
"Tamil Nadu": "33-TN",
"Telangana": "36-TS",
"Tripura": "16-TR",
"Uttar Pradesh": "09-UP",
"Uttarakhand": "05-UK",
"West Bengal": "19-WB"
};
if (!customers[Cust_contents.PartyId]) {
var custSearch = search.create({
type: search.Type.CUSTOMER,
columns: [{
name: 'internalid',
}],
filters: [{
name: 'custentity_jj_crm_party_id',
operator: 'is',
values: [Cust_contents.PartyId]
}]
});
custSearch.run().each(function(result) {
customers[Cust_contents.PartyId] = result.getValue({
name: 'internalid',
});
return false;
});
}
if (!customers[Cust_contents.PartyId]) {
try{
var newCustomer = record.create({
type: record.Type.CUSTOMER,
isDynamic: true,
});
var cust_flag = 0;
newCustomer.setValue({
fieldId: 'externalid',
value: checkForParameter('' + Cust_contents.PartyId)
});
newCustomer.setValue({
fieldId: 'custentity_jj_crm_party_id',
value: checkForParameter('' + Cust_contents.PartyId)
});
newCustomer.setValue({
fieldId: 'companyname',
value: checkForParameter(Cust_contents.OrganizationName)
});
newCustomer.setText({
fieldId: 'category',
text: checkForParameter(Cust_contents.OrganizationDEO_AccountType_c)
});
newCustomer.setValue({
fieldId: 'url',
value: checkForParameter(Cust_contents.OrganizationDEO_ACCWebsite_c)
});
newCustomer.setText({
fieldId: 'custentity1',
text: checkForParameter(Cust_contents.OrganizationDEO_AccountNature_c)
});
try{
newCustomer.setText({
fieldId: 'custentity_jj_industry',
text: checkForParameter(Cust_contents.OrganizationDEO_Industry_c)
});
}
catch(error){
var arr_Industry_setfieldsT=["custentity_jj_industry"];
var arr_Industry_setvaluesT=[Cust_contents.OrganizationDEO_Industry_c];
var industry_Cust=set_CustomFields(arr_Industry_setfieldsT,arr_Industry_setvaluesT,"",cust_flag,"customers");
newCustomer.setText({
fieldId: 'custentity_jj_industry',
text: checkForParameter(industry_Cust)
});
}
newCustomer.setText({
fieldId: 'custentity_jj_account_rating',
text: checkForParameter(Cust_contents.OrganizationDEO_AccountRating_c)
});
newCustomer.setText({
fieldId: 'custentity_jj_region',
text: checkForParameter(Cust_contents.AddressElementAttribute4)
});
if(parent_flag=="true"){
var id_Parent=entityid_custcont("Customers", cust_flag, Cust_contents.ParentAccountPartyId, Cust_contents.ParentAccountName);
newCustomer.setValue({
fieldId: 'parent',
value: id_Parent
});
}
newCustomer.selectNewLine({
sublistId: 'addressbook'
});
var myaddressCust_subrecord = newCustomer.getCurrentSublistSubrecord({
sublistId: 'addressbook',
fieldId: 'addressbookaddress'
});
myaddressCust_subrecord.setValue({
fieldId: 'country',
value: checkForParameter(Cust_contents.Country)
});
if (Cust_contents.Country == "IN") {
myaddressCust_subrecord.setText({
fieldId: 'state',
text: checkForParameter(STATE_MAP[Cust_contents.State])
});
} else {
myaddressCust_subrecord.setText({
fieldId: 'state',
text: checkForParameter(Cust_contents.State)
});
}
myaddressCust_subrecord.setValue({
fieldId: 'addr1',
value: checkForParameter(Cust_contents.AddressLine1)
});
myaddressCust_subrecord.setValue({
fieldId: 'addr2',
value: checkForParameter(Cust_contents.AddressLine2)
});
myaddressCust_subrecord.setValue({
fieldId: 'addr3',
value: checkForParameter(Cust_contents.AddressLine3)
});
myaddressCust_subrecord.setValue({
fieldId: 'city',
value: checkForParameter(Cust_contents.City)
});
myaddressCust_subrecord.setValue({
fieldId: 'zip',
value: checkForParameter(Cust_contents.PostalCode)
});
newCustomer.commitLine({
sublistId: 'addressbook'
});
newCustomer.selectLine({
sublistId: 'taxregistration',
line:0
});
newCustomer.setCurrentSublistText({
sublistId: 'taxregistration',
fieldId: 'nexuscountry',
text:checkForParameter(Cust_contents.OrganizationDEO_AccCountry_c)
});
newCustomer.setCurrentSublistText({
sublistId: 'taxregistration',
fieldId: 'nexusstate',
text:checkForParameter(Cust_contents.State)
});
if(checkForParameter(Cust_contents.State)!=""){
newCustomer.setCurrentSublistText({
sublistId: 'taxregistration',
fieldId: 'nexus',
text:checkForParameter('Nexus-'+Cust_contents.State)
});
}
newCustomer.setCurrentSublistText({
sublistId: 'taxregistration',
fieldId: 'taxregistrationnumber',
text:checkForParameter(Cust_contents.OrganizationDEO_GSTIN_c)
});
newCustomer.commitLine({
sublistId: 'taxregistration'
});
var recId = newCustomer.save({
enableSourcing: true,
ignoreMandatoryFields: true
});
var objRecord = record.load({
type: record.Type.CUSTOMER,
id: recId,
isDynamic: true,
});
objRecord.selectLine({
sublistId: 'taxregistration',
line:0
});
objRecord.setCurrentSublistText({
sublistId: 'taxregistration',
fieldId: 'address',
text:checkForParameter(Cust_contents.AddressLine1)
});
objRecord.commitLine({
sublistId: 'taxregistration'
});
objRecord.setText({
fieldId: 'defaulttaxreg',
text: checkForParameter(Cust_contents.OrganizationDEO_GSTIN_c)
});
var recordId = objRecord.save({
enableSourcing: true,
ignoreMandatoryFields: true
});
customers[Cust_contents.PartyId] = recId;
log.debug({
title: 'Customer_recId',
details: recId
});
if((parent_flag=="false") && (checkForParameter(Cust_contents.PrimaryContactPartyId)!="")){
log.debug("falseflag",Cust_contents.PartyId);
contactcompany_Request(Cust_contents.PartyId);
}
return recId;
}
catch(error){
log.debug("Error@Createcustomers",error);
var cust_Create_error = file.create({
name : 'create_Customer:'+Cust_contents.OrganizationName+':'+Cust_contents.PartyId+'.json',
fileType: file.Type.JSON,
contents:JSON.stringify(error),
folder:'1413',
}).save();
return ;
}
}
else{
log.debug("Customer Already Exist");
}
}
catch(error){
log.debug("Error@Customer",error);
return;
}
}
/*Function to Create and Edit Contacts */
function CE_Contacts(Cont_contents) {
try{
if (!contacts[Cont_contents.PartyId]) {
var contSearch = search.create({
type: search.Type.CONTACT,
columns: [{
name: 'internalid',
}],
filters: [{
name: 'custentity_jj_crm_party_id',
operator: 'is',
values: [Cont_contents.PartyId]
}]
});
contSearch.run().each(function(result) {
contacts[Cont_contents.PartyId] = result.getValue({
name: 'internalid',
});
return false;
});
if (!contacts[Cont_contents.PartyId]) {
try{ var newContact = record.create({
type: record.Type.CONTACT,
isDynamic: true,
});
var cont_flag = 0;
newContact.setValue({
fieldId: 'entityid',
value: checkForParameter(Cont_contents.ContactName)
});
newContact.setValue({
fieldId: 'email',
value: checkForParameter(Cont_contents.EmailAddress)
});
newContact.setText({
fieldId: 'custentity_jj_division',
text: checkForParameter(Cont_contents.PersonDEO_FlxDivisionUnit_c)
});
newContact.setValue({
fieldId: 'salutation',
value: checkForParameter(Cont_contents.SalutoryIntroduction)
});
newContact.setValue({
fieldId: 'firstname',
value: checkForParameter(Cont_contents.FirstName)
});
newContact.setValue({
fieldId: 'lastname',
value: checkForParameter(Cont_contents.LastName)
});
var id_Parent=entityid_custcont("Contacts", cont_flag, Cont_contents.AccountPartyId, Cont_contents.AccountName);
newContact.setValue({
fieldId: 'company',
value:id_Parent
});
newContact.setValue({
fieldId: 'title',
value: checkForParameter(Cont_contents.JobTitle)
});
newContact.setValue({
fieldId: 'mobilephone',
value: checkForParameter(Cont_contents.FormattedMobileNumber)
});
newContact.setValue({
fieldId: 'phone',
value: checkForParameter(Cont_contents.FormattedWorkPhoneNumber)
});
newContact.setText({
fieldId: 'custentity_jj_contact_department',
text: checkForParameter(Cont_contents.PersonDEO_CONDepartment_c)
});
newContact.selectNewLine({
sublistId: 'addressbook'
});
newContact.setValue({
fieldId: 'externalid',
value: checkForParameter('' + Cont_contents.PartyId)
});
newContact.setValue({
fieldId: 'custentity_jj_crm_party_id',
value: checkForParameter('' + Cont_contents.PartyId)
});
var myaddressCust_subrecord = newContact.getCurrentSublistSubrecord({
sublistId: 'addressbook',
fieldId: 'addressbookaddress'
});
myaddressCust_subrecord.setValue({
fieldId: 'country',
value: checkForParameter(Cont_contents.Country)
});
if (Cont_contents.Country == "IN") {
myaddressCust_subrecord.setText({
fieldId: 'state',
text: checkForParameter(STATE_MAP[Cont_contents.State])
});
} else {
myaddressCust_subrecord.setText({
fieldId: 'state',
text: checkForParameter(Cont_contents.State)
});
}
myaddressCust_subrecord.setValue({
fieldId: 'addr1',
value: checkForParameter(Cont_contents.AddressLine1)
});
myaddressCust_subrecord.setValue({
fieldId: 'addr2',
value: checkForParameter(Cont_contents.AddressLine2)
});
myaddressCust_subrecord.setValue({
fieldId: 'addr3',
value: checkForParameter(Cont_contents.AddressLine3)
});
myaddressCust_subrecord.setValue({
fieldId: 'city',
value: checkForParameter(Cont_contents.City)
});
myaddressCust_subrecord.setValue({
fieldId: 'zip',
value: checkForParameter(Cont_contents.PostalCode)
});
newContact.commitLine({
sublistId: 'addressbook'
});
var recId = newContact.save({
enableSourcing: true,
ignoreMandatoryFields: true
});
contacts[Cont_contents.PartyId] = recId;
log.debug({
title: 'Contact_recId',
details: recId
});
}
catch(error){
log.debug("Error@CreateContact",error);
var cont_Create_error = file.create({
name : 'create_Contact:'+Cont_contents.ContactName+':'+Cont_contents.PartyId+'.json',
fileType: file.Type.JSON,
contents:JSON.stringify(error),
folder:'1413',
}).save();
return;
}
}
else{
log.debug("Contact Already Exist");
}
}
}
catch(error){
log.debug("Error@Contacts",error);
return;
}
}
/*Function to Create and Edit Products */
function createdit_Products(cred_Products){
try{
if (!products[cred_Products.InventoryItemId]) {
var prodSearch = search.create({
type: search.Type.INVENTORY_ITEM,
columns: [{
name: 'internalid',
}],
filters: [{
name: 'custitem_jj_crm_inventoryitemid',
operator: 'is',
values: [cred_Products.InventoryItemId]
}]
});
prodSearch.run().each(function(result) {
products[cred_Products.InventoryItemId] = result.getValue({
name: 'internalid',
});
return false;
});
}
/* To Create products to NS when corresponding opportunity is created*/
if (!products[cred_Products.InventoryItemId]) {
try{
newProduct = record.create({
type: record.Type.INVENTORY_ITEM,
isDynamic: true,
});
var flag = 0;
newProduct.setValue({
fieldId: 'itemid',
value: checkForParameter(cred_Products.ItemNumber)
});
newProduct.setValue({
fieldId: 'displayname',
value: checkForParameter(cred_Products.ItemNumber)
});
newProduct.setValue({
fieldId: 'custitem_jj_manufacturer_part_no',
value: checkForParameter(cred_Products.ItemNumber)
});
newProduct.setValue({
fieldId: 'custitem_jj_confirm_manufacturer_part',
value: checkForParameter(cred_Products.Name)
});
newProduct.setValue({
fieldId: 'custitem_jj_make',
value: checkForParameter(cred_Products.Make_c)
});
newProduct.setText({
fieldId: 'custitem_jj_sales_type',
text: checkForParameter(cred_Products.SalesType_c)
});
if (cred_Products.Availability_c !== "null" && cred_Products.Availability_c !== null && cred_Products.Availability_c !== "" && cred_Products.Availability_c !== undefined) {
var arr_Avail_setfieldsT = ["custitem_jj_availability"];
var arr_Avail_setvaluesT = [cred_Products.Availability_c];
set_CustomFields(arr_Avail_setfieldsT, arr_Avail_setvaluesT, "", flag, "products");
}
newProduct.setValue({
fieldId: 'custitem_jj_packing_qty',
value: checkForParameter(cred_Products.PackingQty_c)
});
newProduct.setValue({
fieldId: 'custitem_jj_package_type_outline',
value: checkForParameter(cred_Products.PrdPackageTypeOutline_c)
});
if (cred_Products.PrdProductCategory_c == "Temperature Measurement Access") {
cred_Products.PrdProductCategory_c = cred_Products.PrdProductCategory_c + "ories";
} else if (cred_Products.PrdProductCategory_c == "Anamet Cable Conduit") {
cred_Products.PrdProductCategory_c = cred_Products.PrdProductCategory_c.replace(/^(Anamet )/, "");
}
newProduct.setText({
fieldId: 'custitem_jj_product_category',
text: cred_Products.PrdProductCategory_c
});
newProduct.setText({
fieldId: 'custitem_jj_default_uom',
text: checkForParameter(cred_Products.DefaultUOM)
});
newProduct.setText({
fieldId: ' department',
text: checkForParameter(cred_Products.Department_Netsuite_c)
});
newProduct.setValue({
fieldId: 'salesdescription',
value: checkForParameter(cred_Products.Description)
});
newProduct.setValue({
fieldId: 'purchasedescription',
value: checkForParameter(cred_Products.Description)
});
var hsncode_Desc=product_Hsn(cred_Products.HSNCode_c);
newProduct.setText({
fieldId:'custitem_in_hsn_code',
text:checkForParameter(hsncode_Desc)
});
newProduct.setValue({
fieldId: 'cogsaccount',
value: '116'
});
newProduct.setValue({
fieldId: 'assetaccount',
value: '216'
});
newProduct.setValue({
fieldId: 'incomeaccount',
value: '54'
});
newProduct.setValue({
fieldId: 'custitem_jj_crm_inventoryitemid',
value: checkForParameter('' + cred_Products.InventoryItemId)
});
newProduct.setValue({
fieldId: 'externalid',
value: checkForParameter('' + cred_Products.InventoryItemId)
});
var type = cred_Products.PrdProductCategory_c;
switch (type) {
case "LV Switchgear":
var LV_setfieldsV = ["custitem_jj_lv_switchgear_voltage", "custitem_jj_lvswitchgear_current", "custitem_jj_no_of_poles", "custitem_jj_auxillary_contact", "custitem_jj_coil_voltage", "custitem_jj_setting_range"];
var LV_setvaluesV = [cred_Products.RatedVoltage_c, cred_Products.RatedCurrent_c, cred_Products.PrdLVSwitchgearNoOfPoles_c, cred_Products.PrdLVSwitchgearAuxillaryContact_c, cred_Products.PrdLVSwitchgearCoilVoltage_c, cred_Products.LVSwitchgearSettingRangeOfOLReleaseA_c];
var LV_setfieldsT = ["custitem_jj_lvswitchgear_type", "custitem_jj_application", "custitem_jj_lvswitchgear_duty_class"];
var LV_setvaluesT = [cred_Products.PrdLVSwitchgearType_c, cred_Products.PrdLVSwitchgearApplication_c, cred_Products.PrdLVSwitchgearDutyClass_c];
EditCr_Products(LV_setfieldsV, LV_setvaluesV, LV_setfieldsT, LV_setvaluesT, flag, "LV Switchgear");
break;
case "Fuse":
var Fuse_setfieldsV = ["custitem_jj_private_part_no", "custitem_jj_voltage_rating", "custitem_jj_current_rating"];
var Fuse_setvaluesV = [cred_Products.PrdFusePrivatePartNoLabel_c, cred_Products.RatedVoltage_c, cred_Products.RatedCurrent_c];
var Fuse_setfieldsT = ["custitem_jj_fuse_type", "custitem_jj_contact_version", "custitem_jj_indicating_system"];
var Fuse_setvaluesT = [cred_Products.PrdFuseType_c, cred_Products.PrdFuseContactVersion_c, cred_Products.PrdFuseIndSystem_c];
EditCr_Products(Fuse_setfieldsV, Fuse_setvaluesV, Fuse_setfieldsT, Fuse_setvaluesT, flag, "Fuse");
break;
case "Fuse Accessories":
var FuseA_setfieldsV = ["custitem_jj_fuse_accessories_type"];
var FuseA_setvaluesV = [cred_Products.PRProductType_c];
EditCr_Products(FuseA_setfieldsV, FuseA_setvaluesV, "", "", flag, "Fuse Accessories");
break;
case "Capacitor(IHM)":
var Capacitor_setfieldsV = ["custitem_jj_kvar", "custitem_jj_capacitor_frequecy", "custitem_jj_capacitor_voltage", "custitem_jj_capacitor_length", "custitem_jj_capacitor_breadth", "custitem_jj_capacitor_height", "custitem_jj_phase", "custitem_jj_pressure_switch"];
var Capacitor_setvaluesV = [cred_Products.PrdCapacitorKVAR_c, cred_Products.PrdCapacitorFrequecyHz_c, cred_Products.PrdCapacitorVoltageV_c, cred_Products.PrdCapacitorLength_c, cred_Products.PrdCapacitorBreadth_c, cred_Products.PrdCapacitorHeight_c, cred_Products.PrdCapacitorPhase_c, cred_Products.PrdCapacitorPressureSwitch_c];
var Capacitor_setfieldsT = ["custitem_jj_cap_type", "custitem_jj_no_of_terminals", "custitem_jj_capacitor_type", "custitem_jj_capacitor_case_type"];
var Capacitor_setvaluesT = [cred_Products.PrdCapacitorType_c, cred_Products.PrdCapacitorNoOfTerminals_c, cred_Products.PrdCapacitorBankConnectionType_c, cred_Products.PrdCapacitorCaseType_c];
EditCr_Products(Capacitor_setfieldsV, Capacitor_setvaluesV, Capacitor_setfieldsT, Capacitor_setvaluesT, flag, "Capacitor(IHM)");
break;
case "IGBT":
var IGBT_setfieldsV = ["custitem_jj_igbt_voltage", "custitem_jj_igbt_current", "custitem_jj_igbt_height", "custitem_jj_igbt_width"];
var IGBT_setvaluesV = [cred_Products.PrdIGBTVoltageVCES_c, cred_Products.PrdIGBTCurrentIC_c, cred_Products.PrdIGBTHeightmm_c, cred_Products.PrdIGBTWidthmm_c];
var IGBT_setfieldsT = ["custitem_jj_igbt_type", "custitem_jj_igbt_circuit"];
var IGBT_setvaluesT = [cred_Products.PrdIGBTType_c, cred_Products.PrdIGBTCircuit_c];
EditCr_Products(IGBT_setfieldsV, IGBT_setvaluesV, IGBT_setfieldsT, IGBT_setvaluesT, flag, "IGBT");
break;
case "Bi Polar":
var BiPolar_setfieldsV = ["custitem_jj_bi_polarprivate_part", "custitem_jj_contact_diameter", "custitem_jj_package_height", "custitem_jj_average_current", "custitem_jj_piv"];
var BiPolar_setvaluesV = [cred_Products.PrdBiPolarPrivatePartNoLabel_c, cred_Products.PrdBiPolarContactDiametermm_c, cred_Products.PrdBiPolarPackageHeightmm_c, cred_Products.PrdBiPolarAverageCurrentItAV_c, cred_Products.PrdBiPolarPIV_c];
var BiPolar_setfieldsT = ["custitem_jj_hps_bi_polar_type"];
var BiPolar_setvaluesT = [cred_Products.PrdBiPolarType_c];
EditCr_Products(BiPolar_setfieldsV, BiPolar_setvaluesV, BiPolar_setfieldsT, BiPolar_setvaluesT, flag, "Bi Polar");
break;
case "Encoders":
var Encoders_setfieldsV = ["custitem_jj_ppr"];
var Encoders_setvaluesV = [cred_Products.PrdEncodersPPR_c];
var Encoders_setfieldsT = ["custitem_jj_encoders_type", "custitem_jj_encoders_output_signal", "custitem_jj_encoders_duty_class", "custitem_jj_encoders_supply_voltage", "custitem_jj_bus_output", "custitem_jj_single_turn_resolution", "custitem_jj_multiple_turn", "custitem_jj_construction_type"];
var Encoders_setvaluesT = [cred_Products.PrdEncodersType_c, cred_Products.PrdEncodersOutputSignal_c, cred_Products.PrdEncodersDutyClass_c, cred_Products.PrdSupplyVoltage_c, cred_Products.PrdEncodersBusOutput_c, cred_Products.PrdEncodersSingleTurnResolutionCPRBits_c, cred_Products.PrdEncodersMultipleTurnNoOfRevolutionsBits_c, cred_Products.PrdEncodersConstructionType_c];
EditCr_Products(Encoders_setfieldsV, Encoders_setvaluesV, Encoders_setfieldsT, Encoders_setvaluesT, flag, "Encoders");
break;
case "Loop Scanner":
var LoopScanner_setfieldsV = ["custitem_jj_loop_scanner_type"];
var LoopScanner_setvaluesV = [cred_Products.PRProductType_c];
EditCr_Products(LoopScanner_setfieldsV, LoopScanner_setvaluesV, "", "", flag, "Loop Scanner");
break;
case "Cable Conduit":
var CableConduit_setfieldsV = ["custitem_jj_temperature_withstand", "custitem_jj_internal_dia", "custitem_jj_outer_dia", "custitem_jj_cable_conduit_moc", "custitem_jj_flexibility", "custitem_jj_approvals", "custitem_jj_colour", "custitem_jj_standard_pack_qty", "custitem_jj_compression_resistance", "custitem_jj_type_of_interlocking"];
var CableConduit_setvaluesV = [cred_Products.PrdAnametCableConduitTemperatureWithstand_c, cred_Products.PrdAnametCableConduitInternalDia_c, cred_Products.PrdAnametCableConduitOuterDia_c, cred_Products.PrdAnametCableConduitMOC_c, cred_Products.PrdAnametCableConduitFlexibility_c, cred_Products.PrdAnametCableConduitApprovals_c, cred_Products.PrdAnametCableConduitColour_c, cred_Products.PrdAnametCableConduitStandardPackQty_c, cred_Products.PrdAnametCableConduitCompressionResistance_c, cred_Products.PrdAnametCableConduit_c];
var CableConduit_setfieldsT = ["custitem_jj_cable_conduit_type", "custitem_jj_cable_protection_class"];
var CableConduit_setvaluesT = [cred_Products.PrdCableConduitType_c, cred_Products.PrdAnametCableConduitProtectionClass_c];
EditCr_Products(CableConduit_setfieldsV, CableConduit_setvaluesV, CableConduit_setfieldsT, CableConduit_setvaluesT, flag, "Cable Conduit");
break;
case "Others":
var LoopScanner_setfieldsV = ["custitem_jj_others_type"];
var LoopScanner_setvaluesV = [cred_Products.PRProductType_c];
EditCr_Products(LoopScanner_setfieldsV, LoopScanner_setvaluesV, "", "", flag, "Others");
break;
case "Temperature Measurement Accessories":
var Temp_setfieldsV = ["custitem_jj_temperature_measurement"];
var Temp_setvaluesV = [cred_Products.PRProductType_c];
EditCr_Products(Temp_setfieldsV, Temp_setvaluesV, "", "", flag, "Temperature Measurement Accessories");
break;
case "Pyrometer":
var arr_Pyrometer_setfieldsT = ["custitem_jj_temperature_range", "custitem_jj_spectral_range", "custitem_jj_optical_resolution", "custitem_jj_ambient_temperature", "custitem_jj_output_analogue", "custitem_jj_optionalinterfaces", "custitem_jj_additional_cable_length"];
var arr_Pyrometer_setvaluesT = [cred_Products.PrdPyrometerTemperatureRange_c, cred_Products.PrdPyrometerSpectralRange_c, cred_Products.PrdPyrometerOpticalResolution_c, cred_Products.PrdAmbientTemperature_c, cred_Products.PrdPyrometerOutputAnalogue_c, cred_Products.PrdPyrometerOptionalInterfacesToBeOrderedSeperately_c, cred_Products.PrdPyrometerAdditionalCableLength_c];
set_CustomFields(arr_Pyrometer_setfieldsT, arr_Pyrometer_setvaluesT, "Pyrometer", flag, "products");
var Pyrometer_setfieldsT = ["custitem_jj_pyrometer_type", "custitem_jj_pyrometer_supply_voltage", "custitem_jj_standard_cable_length"];
var Pyrometer_setvaluesT = [cred_Products.PrdPyrometerType_c, cred_Products.PrdSupplyVoltage_c, cred_Products.PrdPyrometerStandardCableLength_c];
EditCr_Products("", "", Pyrometer_setfieldsT, Pyrometer_setvaluesT, flag, "Pyrometer");
break;
case "Thermal Imaging Camera":
var arr_Thermal_setfieldsT = ["custitem_jj_thermal_optical_resolution", "custitem_jj_standard_temperature_range", "custitem_jj_additional_callibration"];
var arr_Thermal_setvaluesT = [cred_Products.PrdThermalImagingCameraOpticalResolution_c, cred_Products.PrdThermalImagingCameraStandardTemperatureRange_c, cred_Products.PrdThermalImagingCameraAdditionalCalibrationRange_c];
set_CustomFields(arr_Thermal_setfieldsT, arr_Thermal_setvaluesT, "Thermal Imaging Camera", flag, "products");
var Thermal_setfieldsV = ["custitem_jj_lens"];
var Thermal_setvaluesV = [cred_Products.PrdThermalImagingCameraLensFOV_c];
var Thermal_setfieldsT = ["custitem_jj_thermal_imag_camera_type", "custitem_jj_thermal_imaging_supply", "custitem_jj_thermal_sensitivity"];
var Thermal_setvaluesT = [cred_Products.PrdThermalImagingCameraType_c, cred_Products.PrdSupplyVoltage_c, cred_Products.PrdThermalImagingCameraThermalSensitivityNETD_c];
EditCr_Products(Thermal_setfieldsV, Thermal_setvaluesV, Thermal_setfieldsT, Thermal_setvaluesT, flag, "Thermal Imaging Camera");
break;
case "Proximity":
var arr_Proximity_setfieldsT = ["custitem_jj_proximity_ambient_temp", "custitem_jj_connection", "custitem_jj_proximity_output", ];
var arr_Proximity_setvaluesT = [cred_Products.PrdAmbientTemperature_c, cred_Products.PrdProximityConnection_c, cred_Products.PrdOutput_c];
set_CustomFields(arr_Proximity_setfieldsT, arr_Proximity_setvaluesT, "Proximity", flag, "products");
var Proximity_setfieldsV = ["custitem_jj_proximity_accessories"];
var Proximity_setvaluesV = [cred_Products.PrdProximityAccessories_c];
var Proximity_setfieldsT = ["custitem_jj_proximity_type", "custitem_jj_operating_distance", "custitem_jj_proximity_housing_size", "custitem_jj_moc", "custitem_jj_protection_class", "custitem_jj_mounting", "custitem_jj_no_of_wires", "custitem_jj_proximity_supply_voltage", "custitem_jj_cable_moc", "custitem_jj_cable_length"];
var Proximity_setvaluesT = [cred_Products.PrdProximityType_c, cred_Products.PrdProximityOperatingDistance_c, cred_Products.PrdProximityHousingSize_c, cred_Products.PrdProximityMOC_c, cred_Products.PrdProximityProtectionClass_c, cred_Products.PrdProximityMounting_c, cred_Products.PrdProximityNoofWires_c, cred_Products.PrdSupplyVoltage_c, cred_Products.PrdProximityCableMOC_c, cred_Products.PrdProximityCableLength_c];
EditCr_Products(Proximity_setfieldsV, Proximity_setvaluesV, Proximity_setfieldsT, Proximity_setvaluesT, flag, "Proximity");
break;
case "HMD":
var arr_HMD_setfieldsT = ["custitem_jj_response_temperature", "custitem_jj_hmd_output", "custitem_jj_hmd_interface_options", "custitem_jj_fov"];
var arr_HMD_setvaluesT = [cred_Products.PrdHMDResponseTemperature_c, cred_Products.PrdOutput_c, cred_Products.PrdInterfaceOptions_c, cred_Products.PrdHMDFOV_c];
set_CustomFields(arr_HMD_setfieldsT, arr_HMD_setvaluesT, "HMD", flag, "products");
var HMD_setfieldsT = ["custitem_jj_hmd_type", "custitem_jj_hmd_supply_voltage", "custitem_jj_cooling", "custitem_jj_hmd_housing"];
var HMD_setvaluesT = [cred_Products.PRProductType_c, cred_Products.PrdSupplyVoltage_c, cred_Products.PrdHMDCooling_c, cred_Products.PrdHMDHousing_c];
EditCr_Products("", "", HMD_setfieldsT, HMD_setvaluesT, flag, "HMD");
break;
case "Light Barrier":
var arr_Barrier_setfieldsT = ["custitem_jj_light_barrier_photo_out", "custitem_jj_light_barrier_ambient_temp"];
var arr_Barrier_setvaluesT = [cred_Products.PrdOutput_c, cred_Products.PrdAmbientTemperature_c];
set_CustomFields(arr_Barrier_setfieldsT, arr_Barrier_setvaluesT, "Light Barrier", flag, "products");
var Barrier_setfieldsV = ["custitem_jj_dimensions"];
var Barrier_setvaluesV = [cred_Products.PrdLightBarrierDimensions_c];
var Barrier_setfieldsT = ["custitem_jj_light_barrier_photocell", "custitem_jj_sensing_range", "custitem_jj_light_barrier_housing"];
var Barrier_setvaluesT = [cred_Products.PrdLightBarrierPhotocellType_c, cred_Products.PrdLightBarrierPhotocellSensingRange_c, cred_Products.PrdLightBarrierHousing_c];
EditCr_Products(Barrier_setfieldsV, Barrier_setvaluesV, Barrier_setfieldsT, Barrier_setvaluesT, flag, "Light Barrier");
break;
case "Laser Distance Metre":
var arr_Laser_setfieldsT = ["custitem_jj_accuracy", "custitem_jj_ldm_ambient_temperature", "custitem_jj_ldm_interface_options"];
var arr_Laser_setvaluesT = [cred_Products.PrdLaserDistanceMetreAccuracy_c, cred_Products.PrdAmbientTemperature_c, cred_Products.PrdInterfaceOptions_c];
set_CustomFields(arr_Laser_setfieldsT, arr_Laser_setvaluesT, "Laser Distance Metre", flag, "products");
var Laser_setfieldsV = ["custitem_jj_response_time", "custitem_jj_measuring_frequency", "custitem_jj_divergence", "custitem_jj_ldm_dimensions"];
var Laser_setvaluesV = [cred_Products.PrdLaserDistanceMetreResponseTime_c, cred_Products.PrdLaserDistanceMetreMeasuringFrequency_c, cred_Products.PrdLaserDistanceMetreDivergence_c, cred_Products.PrdLaserDistanceMetreDimensions_c];
var Laser_setfieldsT = ["custitem_jj_laser_dist_meter_type", "custitem_jj_measuring_distance", "custitem_jj_laser_class", "custitem_jj_laser_distance_metre_out", "custitem_jj_ldm_supply_voltage", "custitem_jj_ldm_protection_class", "custitem_jj_switching_digital_output"];
var Laser_setvaluesT = [cred_Products.PrdLaserDistanceMeterType_c, cred_Products.PrdLaserDistanceMetreMeasuringDistance_c, cred_Products.PrdLaserDistanceMetreLaserClass_c, cred_Products.PrdLaserDistanceMetreOutput_c, cred_Products.PrdSupplyVoltage_c, cred_Products.PrdLaserDistanceMetreProtectionClass_c, cred_Products.PrdLaserDistanceMetreSwitchingDigitalOutput_c];
EditCr_Products(Laser_setfieldsV, Laser_setvaluesV, Laser_setfieldsT, Laser_setvaluesT, flag, "Laser Distance Metre");
break;
}
var recId = newProduct.save({
enableSourcing: true,
ignoreMandatoryFields: true
});
products[cred_Products.InventoryItemId] = recId;
log.debug({
title: 'Prod recId',
details: recId
});
}
catch(error){
log.debug("error@CreateProducts",error);
var prod_Create_error = file.create({
name : 'create_Product:'+cred_Products.Name+':'+cred_Products.InventoryItemId+'.json',
fileType: file.Type.JSON,
contents:JSON.stringify(error),
folder:'1413',
}).save();
return;
}
}
else{
log.debug("Product Already Exist");
}
}
catch(error){
log.debug("Error@Products",error);
return;
}
}
function EditCr_Products(P_setfieldsV, P_setvaluesV, P_setfieldsT, P_setvaluesT, P_flag, P_category) {
if (P_flag == 0) {
try{
for (var i = 0; i < P_setfieldsV.length; i++) {
newProduct.setValue({
fieldId: P_setfieldsV[i],
value: checkForParameter(P_setvaluesV[i])
});
}
for (var j = 0; j < P_setfieldsT.length; j++) {
try{newProduct.setText({
fieldId: P_setfieldsT[j],
text: checkForParameter(P_setvaluesT[j])
});
}
catch(error){
set_CredcustomFields(P_setfieldsT[j],P_setvaluesT[j],P_flag,P_category);
}
}
}
catch(error){
log.debug("Error@Edit_Products",error);
}
} else if(P_flag == 1) {
try{
for (var i = 0; i < P_setfieldsV.length; i++) {
ProdobjRecord.setValue({
fieldId: P_setfieldsV[i],
value: checkForParameter(P_setvaluesV[i])
});
}
for (var j = 0; j < P_setfieldsT.length; j++) {
try{
ProdobjRecord.setText({
fieldId: P_setfieldsT[j],
text: checkForParameter(P_setvaluesT[j])
});
}
catch(error){
set_CredcustomFields(P_setfieldsT[j],P_setvaluesT[j],P_flag,P_category);
}
}
}
catch(error){
log.debug("Error@Edit_Products",error);
}
}
}
/*function to set values from custom record*/
function set_CustomFields(arr_field, arr_values, S_category, SP_flag, int_Type) {
for (var i = 0; i < arr_values.length; i++) {
for (var j = 0; j < item_Objdetails.length; j++) {
if (((item_Objdetails[j].name == escape_for_xml(arr_values[i])) && (S_category == item_Objdetails[j].category)) || (item_Objdetails[j].name == escape_for_xml(arr_values[i]) && item_Objdetails[j].category == "")) {
if (SP_flag == 0&& int_Type=="products") {
try{
newProduct.setText({
fieldId: arr_field[i],
text: checkForParameter(escape_for_xml(item_Objdetails[j].value))
});
}
catch(error){
log.debug("Error@set_CrCustomVFieldsp",error);
}
} else if(SP_flag == 1&& int_Type=="products") {
try{
ProdobjRecord.setText({
fieldId: arr_field[i],
text:checkForParameter(escape_for_xml(item_Objdetails[j].value))
});
}
catch(error){
log.debug("Error@set_EDCustomVFieldsp",error);
}
}
else if(SP_flag == 0&& int_Type=="customers") {
try{
return item_Objdetails[j].value;
}
catch(error){
log.debug("Error@set_CRCustomVFieldsc",error);
}
}
else if(SP_flag == 1&& int_Type=="customers") {
try{
return item_Objdetails[j].value;
}
catch(error){
log.debug("Error@set_EDCustomVFieldsc",error);
}
}
}
}
}
}
/*function to set parent company for customers and company for contacts*/
function entityid_custcont(entityid_flag, entityid_custcontflag, entityid_id, entityid_contents) {
var filterArr = [];
var Cont_Companyid;
var search_flag = 0;
if (entityid_flag == "Contacts" && entityid_id !== "" && entityid_id !== null && entityid_id !== undefined) {
filterArr = [];
filterArr.push(["custentity_jj_crm_party_id", "is", entityid_id.toString()]);
search_flag = 1;
} else if (entityid_flag == "Customers" && entityid_contents !== "" && entityid_contents !== null && entityid_contents !== undefined) {
Cont_CompanyM=[];
Cont_CompanyM.push(entityid_contents.toString());
filterArr = [];
filterArr.push(["custentity_jj_crm_party_id", "is", entityid_id.toString()]);
search_flag = 1;
}
else if(entityid_flag == "Customers" && entityid_contents == "" && entityid_contents == null && entityid_contents == undefined){
search_flag = 0;
}
if (search_flag == 1) {
try{
var cont_custSearch = search.create({
type: search.Type.CUSTOMER,
filters: filterArr,
columns: [{
name: 'entityid',
},
{
name: 'internalid',
}]
});
cont_custSearch.run().each(function(result) {
Cust_entityid = result.getValue({
name: 'entityid',
});
Cont_Companyid = result.getValue({
name: 'internalid',
});
return false;
});
}
catch(error){
log.debug("Error@entityid_custcont",error);
}
}
else{
Cont_Companyid="";
}
if(Cont_Companyid==""||Cont_Companyid==" "||Cont_Companyid==null||Cont_Companyid==undefined){
if(entityid_flag == "Customers"){
Cont_Companyid=parentcompany_Request(entityid_id);
return Cont_Companyid;
}
else if(entityid_flag == "Contacts"){
Cont_Companyid="";
}
}
else{
return Cont_Companyid;
}
}
/*function to convert strings with special characters*/
function escape_for_xml(argument) {
if(argument.indexOf('<')!=-1){
argument = argument.replace(/</g, '<');
return argument;
}
else if(argument.indexOf('>')!=-1){
argument = argument.replace(/>/g, '>');
return argument;
}
else if(argument.indexOf('<')!=-1){
argument = argument.replace(/</g, '<');
return argument;
}
else if(argument.indexOf('>')!=-1){
argument = argument.replace(/>/g, '>');
return argument;
}
else{
return argument;
}
}
//To check whether a value exists in parameter and set empty
function checkForParameter(parameter) {
if (parameter != "" && parameter !== null && parameter !== undefined && parameter !== false && parameter !== "null" && parameter !== "undefined" && parameter !== 'false' && parameter != " ") {
return parameter;
} else {
parameter = "";
return parameter;
}
}
/*function to set values from custom record if errored when settext*/
function set_CredcustomFields(set_Field,set_Value,set_Flag,set_Category){
for (var i = 0; i < item_Objdetails.length; i++) {
if ((item_Objdetails[i].name==set_Value && item_Objdetails[i].category == "")||((item_Objdetails[i].name==set_Value) && (item_Objdetails[i].category==set_Category))){
if (set_Flag == 0) {
try{
newProduct.setText({
fieldId: set_Field,
text: item_Objdetails[i].value
});
}
catch(error){
log.debug("Error@set_CrCredcustomFields",error);
}
} else if(set_Flag == 1) {
try{
ProdobjRecord.setText({
fieldId: set_Field,
text: item_Objdetails[i].value
});
}
catch(error){
log.debug("Error@set_EDCredcustomFields",error);
}
}
}
}
}
function product_Hsn(hsn_code){
var hsn_id;
var hsn_Name;
if(hsn_code!==""||hsn_code!==" "||hsn_code!==null||hsn_code!==undefined){
var product_HsnSearch = search.create({
type: "customrecord_in_gst_hsn_code_for_service",
filters: [{
name: 'custrecord_in_gst_hsn_code',
operator: 'is',
values: hsn_code
}],
columns: [{
name: 'name',
},
{
name: 'internalid',
}
]
});
product_HsnSearch.run().each(function(result) {
hsn_Name = result.getValue({
name: 'name',
});
hsn_id = result.getValue({
name: 'internalid',
});
return false;
});
}
if(hsn_Name==""||hsn_Name==" "||hsn_Name==null||hsn_Name==undefined){
hsn_Name="";
return hsn_Name;
}
else{
return hsn_Name;
}
}
/*API for creating a customer a parent company of a customer*/
function parentcompany_Request(parent_Id){
log.debug("parentcompany_Request",parent_Id);
var parentcompany_Custresponse=[];
parentcompany_Custresponse.push(JSON.parse(https.get({
url: 'https://eheg.fa.em2.oraclecloud.com/crmRestApi/resources/11.13.18.05/accounts?q=PartyId='+parent_Id+'',
headers: {
authorization: auth_header,
accept: 'application/json'
}
}).body));
for(var i=0;i<parentcompany_Custresponse.length;i++){
for(var j=0;j<parentcompany_Custresponse[i].items.length;j++){
var parent_Inid=CE_customer(parentcompany_Custresponse[i].items[j],"false");
return parent_Inid;
}
}
}
/*API for creating a customer a parent company of a customer*/
function contactcompany_Request(contactparent_Id){
var company_Contactresponse=[];
company_Contactresponse.push(JSON.parse(https.get({
url: 'https://eheg.fa.em2.oraclecloud.com/crmRestApi/resources/11.13.18.05/contacts?q=AccountPartyId='+contactparent_Id+'',
headers: {
authorization: auth_header,
accept: 'application/json'
}
}).body));
for(var i=0;i<company_Contactresponse.length;i++){
for(var j=0;j<company_Contactresponse[i].items.length;j++){
CE_Contacts(company_Contactresponse[i].items[j]);
}
}
}
function findPending(){
var fileSearchObj = search.create({
type: "file",
filters: [
["folder", "anyof", 2913]
],
columns: [
search.createColumn({
name: "internalid",
label: "Internal ID"
}),
search.createColumn({
name: "name",
sort: search.Sort.ASC,
label: "Name"
})
]
});
var searchResultCount = fileSearchObj.runPaged().count;
if (searchResultCount < 1) {
return false
} else {
var internalid;
fileSearchObj.run().each(function(result) {
internalid = result.getValue("internalid");
return true;
});
return internalid;
}
}
function scheduleanother(OptyId,OptyNumber,TargetId){
try{
var scheduleScrptTask = task.create({
taskType: task.TaskType.SCHEDULED_SCRIPT,
scriptId: "customscript_me202jjssintegratecusconpro",
deploymentId: "customdeploy_me202jjssintegratecusconpro",
params: {
custscript__optyid: OptyId,
custscript__optynumber: OptyNumber,
custscript__targetid:TargetId
}
});
scheduleScrptTask.submit();
}
catch(error){
}
}
});