X

It's All About the Platform.

Accessing Product Groups and Items Via Groovy

Richard Bingham
Senior Development Manager

Developing customizations that include the product-items and product-groups associated with Sales Cloud objects (Opportunities) is possible through the use of a specific set of artifacts exposed in Application Composer. This article looks at the three main methods for this.

Firstly access groups/items currently associated with the in-context object. This is the easiest method, where Product Groups and Items details are accessible via Related Objects and Collections. As such if you consult the Groovy Palette you'll see these, such as below for Opportunities.  Which exact object to use will depend on the data you need to access.

Secondly access data that is not currently assigned to the in-context object, using the NewView method on one of the available View Objects. The following example is from a Formula Field which looks up a custom field on the Product Group that matches the query.

def vo = newView('ProductGroupDetailBase') 
if (vo.first() == null){  return "nothing" } else { println('groups found') 
def vc = newViewCriteria(vo) 
def vcr = vc.createRow() 
def vci = vcr.ensureCriteriaItem('ProdGroupId1')  
vci.setOperator('=') 
vci.setValue(nvl(custField_c, 0)) 
vc.insertRow(vcr) 
vo.appendViewCriteria(vc) 
vo.executeQuery() 
 while(vo.hasNext()){ 
   def p = vo.next() 
   return nvl(p.GroupCustomNote_c, 0) } } 

Finally, you could define and use Web Services for accessing all product groups and items. The following notes give some good examples

Be the first to comment

Comments ( 0 )
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.