locked
Appending the account name to an appointment subject line. RRS feed

  • Question

  • Hi,

    When we add an appointment to an account in CRM 4.0, I'd like to be able to append the account name to the begining of the Subjct line.

    The reason for this is so that the account name shows up as the first part of the title of the appointment in our Outlook calendars.

    Does anyone know how I can customise this within CRM 4.0?

    Best Regards

    Dave C
    Dave C
    Tuesday, February 9, 2010 4:45 PM

Answers

  • If you create new appointment sobject is empty.

    You migth try this code
    if(crmForm.FormType == 1)
    {
    crmForm.all.subject.DataValue = crmForm.all.regardingobjectid.DataValue[0].name + ': ";
    }

    You must know that this will work only when you create appointement from account. It that case regarding will be filled, otherwise it will be empty.

    Maybe a better choise is to use onsave event:
    if(crmForm.FormType == 1)
    {
    crmForm.all.subject.DataValue = crmForm.all.regardingobjectid.DataValue[0].name + ': ' + crmForm.all.subject.DataValue;
    }
    I think it would be more reliable solution.


    David Kolodziejczyk
    http://team4crm.com
    • Marked as answer by Dave Challen Tuesday, February 9, 2010 10:25 PM
    Tuesday, February 9, 2010 10:06 PM

All replies

  • on the onsave event you can do that so that every appointment is created with the accoutnname pre-appended.

    go to customizaton==> open appointment entity ==> form and then enter the fllowing code in the onsave() event and publish the entity.

    function onSave()
    {

    crmForm.all.subject.DataValue = crmForm.all.regardingobjectid.DataValue[0].name + crmForm.all.subject.DataValue;

    }

    note, you can also do the same in a plugin (pre create/pre-update.)
    Tuesday, February 9, 2010 4:57 PM
  • function onSave()
    {
    	if(crmForm.FormType == 1)
    	{
    		crmForm.all.subject.DataValue = crmForm.all.regardingobjectid.DataValue[0].name + crmForm.all.subject.DataValue;
    	}
    }
    Check FormType to append account name only on create form, not update.

    You can also check if subject contains account name, if not  then append.

    You can do the same in workflow without programming.

    David Kolodziejczyk
    http://team4crm.com
    Tuesday, February 9, 2010 5:04 PM
  • Thanks for the feedback... on thinking, I've added this code to onLoad rather than onSave so that the when the form is opened the account name is entered automatically into the subject field.

    That said, I copied the following code into the onLoad event: (missing out the leading function onLoad() and last } as I don't believe these are needed?!?!

    if(crmForm.FormType == 1)
    {
    crmForm.all.subject.DataValue = crmForm.all.regardingobjectid.DataValue[0].name + crmForm.all.subject.DataValue;
    }

    When I create a new appointment the account name is entered into the Subject field, but it adds the word null straight after the account name, no spaces. Can you suggest why this is. I'd like to enter a colon after the name and a space to tidy the entry up, how can this be done? 

    Many thanks for the prompt responses. 

    Dave C 

    Dave C
    Tuesday, February 9, 2010 9:57 PM
  • If you create new appointment sobject is empty.

    You migth try this code
    if(crmForm.FormType == 1)
    {
    crmForm.all.subject.DataValue = crmForm.all.regardingobjectid.DataValue[0].name + ': ";
    }

    You must know that this will work only when you create appointement from account. It that case regarding will be filled, otherwise it will be empty.

    Maybe a better choise is to use onsave event:
    if(crmForm.FormType == 1)
    {
    crmForm.all.subject.DataValue = crmForm.all.regardingobjectid.DataValue[0].name + ': ' + crmForm.all.subject.DataValue;
    }
    I think it would be more reliable solution.


    David Kolodziejczyk
    http://team4crm.com
    • Marked as answer by Dave Challen Tuesday, February 9, 2010 10:25 PM
    Tuesday, February 9, 2010 10:06 PM
  • Perfect... thanks for all the assistance with this.

    It's a learning curve, but a fun one.

    Dave C
    Dave C
    Tuesday, February 9, 2010 10:25 PM
  • David,

    One last thing... I've just tried this with the Lead entity, but instead of the Account name being entered ( there isn't one as it's a Lead ) the Contact Name of the Lead is entered.

    I'd need the Lead Company Name entering instead. How would I find the value to use in this case?

    Sorry to be a pain.

    Dave C
    Dave C
    Tuesday, February 9, 2010 10:42 PM
  • In that case you will need to retrieve companyname attribute from lead using javascript web service request.

    Examples:

    David Kolodziejczyk
    http://team4crm.com
    Tuesday, February 9, 2010 10:50 PM
  • Ouch... thought I was doing well until I clicked on the link, that's left me feeling a little cold. 

    Can you provide me with any pointers on how to use this... apologies, but I'm no developer or programer, but I do pick things up quickly. 

    Thanks again for the pointers... Dave C 
    Dave C
    Tuesday, February 9, 2010 11:05 PM