Scripting Example |
Event: Sale closed Do: Create follow-up appointment ‘phone-out’ with text ‘Talk to the CTO’
We create a VBscript file in SO_ARC\Scripts\ folder called my-first-script.vbs
Sub OnCurrentSaleStatusChanged(oldstatus, newstatus) If newstatus = 2 Then ' 2 = sale closed kTaskTable = 67 Set newAppnt = Database.CreateAppointment newAppnt.SetDefaults newAppnt.Contact = CurrentSale.Contact newAppnt.Person = CurrentSale.Person newAppnt.Project = CurrentSale.Project newAppnt.Task = GetListItem( kTaskTable, 236 ) newAppnt.Description = "Talk to the CIO" newAppnt.Save Context. newAppnt End if End Sub
Elements to note: * To activate a script file, copy it into SO_ARC\Scripts and enable it via SOAdmin Scripting Panel * The script filename can be anything. * The script code is all inside a sub-routine that is called by SOCRM.EXE when the sale status changes. * The OnCurrentSaleStatusChanged is not a normal OnFieldChanged event – it is triggered during a sale save if the status has been modified since the sale was loaded. * The Database, GetListItem and Context objects are all part of the SOApplication object – which we have added as an "intrinsic object" – so we don’t have to say "Application.Database" – we can just say "Database" and the scripting engine will figure it out for us.
Up: Scripting Engine Prev: Design Next: Workflow Edit