Scripting

  • 1.  Hi all, I have a CRM Table script that updates

    Posted 11-05-2015 14:34
    Hi all, I have a CRM Table script that updates the location for an appointment when a user saves the appointment. It updates the location field with the address1 and city of the company the appointment is setup for. This works, except the user does not see the location unless they go back into the appointment and look. here is the code: Goto Administration>>Customization>>Communication Next choose the Table Scripts tab Then create a new Script called DefaultLocationAddress In the function InsertRecord area put in the following code: ***********code starts here************************ function InsertRecord() { // Handle insert record actions here { //default address on new communications written by TI 11.4.2015 //first get the primary address id for the company you are entering the appointment for var myCompRecordId = CRM.GetContextInfo('company','Comp_PrimaryAddressId'); //next build a sql query looking for the addressid = companyprimaryaddressid var strSQL = ""Addr_AddressId =""+ myCompRecordId; //now issue the sql query to the 'address' table var myAddrRecord = CRM.FindRecord('Address', strSQL); //fill in the location field with the addr_address1 field from the query returned record //Values('comm_location') = myAddrRecord.addr_Address1; //This one returns just the address1 Values('comm_location') = myAddrRecord.addr_Address1 + "" "" + myAddrRecord.Addr_City; //this one returns addr1 and the city } } ***************code ends here******************** This works and updates the Location but only after the record is saved. I would like to have it update once the user enters something in the Details Subject line while in the appointment. This appears to be something we'd need to do with a field level script. i tried copy/pasting my code into the field level area, but it doesnt work properly there. I think the biggest issue is the visibility to the company (getcontextinfo - company table is not available here??) and the sql query syntax. I have spent time in the Sage CRM help, but cannot get the sql part figured out. Is this possible in the field level scripting or is that only in table level scripts? Thank you for any direction! Marc


  • 2.  RE: Hi all, I have a CRM Table script that updates

    Posted 11-05-2015 14:39
    Field level scripts are the way to go. You will need to complete rewrite it though. Quick answer because I'm on mobile.