You need to sign in to do that
Don't have an account?
brandfarliga
How to find
Hello!
I am in the process of building a javascript function and I am needing some assistance. I want to be able to query all of a Opportunity's products to see if the field called Publisher__c = EAP for any record. If any of the records have the value of EAP in Publisher field, I would like to return a value of true. If not, return else. I need this information so I can pull the true or false value into another function to dictate what type of documents i need to pull.
I am in the process of building a javascript function and I am needing some assistance. I want to be able to query all of a Opportunity's products to see if the field called Publisher__c = EAP for any record. If any of the records have the value of EAP in Publisher field, I would like to return a value of true. If not, return else. I need this information so I can pull the true or false value into another function to dictate what type of documents i need to pull.
function getContractType (oppId) { var result = sforce.connection.query("Select PricebookEntry.Product2.Name, PricebookEntry.Product2.Publisher__c From OpportunityLineItem where OpportunityId = '" + oppId + "' and PricebookEntry.Product2.Publisher__c = "EAP""); if(!result || result['size'] != 1) { return FALSE; } var opplineitem = result.getArray('records')[0]; return opplineitem.Product2; } var EbayContract = getContractType('{!Opportunity.Id}');
There is no "Product2" field on opportunityLineItem. There is only a Product2Id field, which you should be adding to the query.
Is there any other assistance you are looking for? Please provide specifics.
Thanks,
Shashank
var result = sforce.connection.query("Select PricebookEntry.Product2.Name, PricebookEntry.Product2.Publisher__c From OpportunityLineItem where OpportunityId = '" + oppId + "' and PricebookEntry.Product2.Publisher__c = 'EAP' ");
How could I change this so I could return the number of results from the query? Would I just need to change the return statement to result['size'] to get a count of how many query results I got? I want to to be able to call this function in another piece of code so if getProductTypes() is less than 1, run this code, else run this other code.