i have a Java script button that is throwing an error message but is still working. Its only throwing this error for some users so I believe its about permissions but its not obvious what it is? I wondered if anyone recognises this?
Here is the button script if that helps:
{!REQUIRESCRIPT("/soap/ajax/34.0/connection.js")}
var subMirrorId = '{!OpportunityLineItem.Opportunity_Product_MirrorId__c}';
if(subMirrorId == null || subMirrorId == ''){
var oppProduct = new sforce.SObject("OpportunityLineItem");
var oppProdMirror = new sforce.SObject("Opportunity_Product_Mirror__c");
var mirrorLookup = '{!OpportunityLineItem.Opportunity_Product_MirrorId__c}';
oppProduct.Id = '{!OpportunityLineItem.Id}';
var queryRes = sforce.connection.query("Select UnitPrice, Quantity, TotalPrice, Product2Id, CurrencyIsoCode, SB_Quantity__c, Segment_Index__c, Description, Start_Date__c, End_Date__c, OpportunityId From OpportunityLineItem Where Id = '" + oppProduct.Id + "' LIMIT 1");
var records = queryRes.getArray("records");
oppProdMirror.Quantity__c = records[0].Quantity;
oppProdMirror.Sales_Price__c = records[0].UnitPrice;
oppProdMirror.Opportunity_Product_Id__c = '{!OpportunityLineItem.Id}';
oppProdMirror.Product__c = records[0].Product2Id;
oppProdMirror.Opportunity__c = records[0].OpportunityId;
oppProdMirror.Total_Price__c = records[0].TotalPrice;
oppProdMirror.CurrencyIsoCode = records[0].CurrencyIsoCode;
oppProdMirror.SBQQ_Quantity__c = records[0].SB_Quantity__c;
oppProdMirror.Description__c = records[0].Description;
oppProdMirror.Segment_Index__c = records[0].Segment_Index__c;
oppProdMirror.Start_Date__c= records[0].Start_Date__c;
oppProdMirror.End_Date__c = records[0].End_Date__c;
var oppProductMirrorInsertRes = sforce.connection.create([oppProdMirror]);
if(oppProductMirrorInsertRes[0].getBoolean("success")){
oppProduct.Opportunity_Product_Mirror__c = oppProductMirrorInsertRes[0].id;
var oppProdUpdRes = sforce.connection.update([oppProduct]);
if(oppProdUpdRes[0].getBoolean("success")){
window.top.location.href = '/' + oppProductMirrorInsertRes[0].id
}
else{
alert('Error creating sub item container: ' + oppProdUpdRes[0]);
}
}
else{
alert('Error creating sub item container: ' + oppProductMirrorInsertRes[0]);
}
}
else{
window.top.location.href = '/' + subMirrorId;
}
Description