• brandfarliga
  • NEWBIE
  • 0 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 0
    Replies
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.

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}');