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

Script working inside a trigger but breaking inside an object function, why

edited Dec 28, 2018 7:36PM in Sales 8 comments

Content

I'm working on a custom object. When I run a script from a trigger it works but if I run the same code from an object function, it throws an error saying "Cannot invoke method getAttribute() on null object". The script populates a long text field with a lead's property:

 
def vo = newView('Lead')
def foundRows = vo.findByKey(key(100000222932042),1)
def foundRow = foundRows[0]
setAttribute('LongTextField_c', foundRow.getAttribute('PrimaryContactPersonLastName'))
 

Any clue about this strange behavior? How can it be surpassed?

Howdy, Stranger!

Log In

To view full details, sign in.

Register

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