How do I assign an opportunity close date to a lead field using Groovy?
You can create a Before Update trigger on your Opportunity object to identify the associated lead or leads that you want to assign the opportunity close date and then insert the value of the field with whatever value you need.
You can use this sample Groovy script to help you get started.
def a = OpportunityLead
def f = ''
while (a.hasNext()){
def d = a.next()
f = f + ' - ' + d.LeadId
}
//throw new oracle.jbo.ValidationException('The lead ID is ' + f)
println('Leads - ' + f)
def vo = newView('Lead')
def vc = newViewCriteria(vo)
def vcr = vc.createRow()
def vci = vcr.ensureCriteriaItem('LeadId')
vci.setOperator('=')
vci.setValue(/*get the value from previously found leads*/)
vc.insertRow(vcr)
vo.appendViewCriteria(vc)
vo.setMaxFetchSize(500)
vo.executeQuery()