You're almost there! Please answer a few more questions for access to the Applications content. Complete registration
Interested in joining? Complete your registration by providing Areas of Interest here. Register

How to get Product Name from Opportunity using Groovy

Accepted answer
32
Views
2
Comments
in Sales 2 comments

I have a requirement to concatenate Account Name + Product Name as Opportunity Name in Opportunity creation page. I use BeforeInsert object trigger for this. I can get the Account name but I find it hard to get the Product name when I select a product item in the name field.


Please modify my groovy script, as this get the first existing element (product) not the product I selected.


// Set Opportunity Name to Account Name + Product

def voProduct = newView('Product');

def vcProduct = voProduct.createViewCriteria();

def vcrProduct = vcProduct.createRow();

vcProduct.insertRow(vcrProduct);

voProduct.appendViewCriteria(vcProduct);

voProduct.executeQuery();

def prodName = voProduct.first()?.getAttribute('Name');

Howdy, Stranger!

Log In

To view full details, sign in.

Register

Don't have an account? Click here to get started!