fiogf49gjkf0d I am trying to verify the price on in the Products associated with an Opportunity before the Opportunity can be set to 'Won'. However, my attempt to access the Opportunity Product(s) always returns a null value regardless of if there are products or not. I have tried two different methods for getting the Opportunity Products...
A)
System.Collections.Generic.IList<IOpportunityProduct> objOppProdList = opportunity.Products as System.Collections.Generic.IList<IOpportunityProduct>;
and B)
Sage.Platform.RepositoryHelper<Sage.Entity.Interfaces.IOpportunityProduct> objRepHelp = Sage.Platform.EntityFactory.GetRepositoryHelper<Sage.Entity.Interfaces.IOpportunityProduct>(); Sage.Platform.Repository.ICriteria objCriteria = objRepHelp.CreateCriteria(); objCriteria.Add(objRepHelp.EF.Eq("OPPORTUNITYID", opportunity.Id.ToString())); System.Collections.Generic.IList<IOpportunityProduct> objOppProdList = objCriteria.List<IOpportunityProduct>();
They both compile fine however when in SLX (7.5.4) I get an error box that says "Sage.SalesLogix.Entities.OpportunityProduct". The error goes away when I get rid of the criteria of opportunityid = opportunity.id.tostring() line. I know there is at least one product in the opportunity because I can see it.
Any suggestions? |