Stock SSA Behavior on Tasks

I am looking to break the association on the stock 'Add Task' screen SSA fields between Company, Person, and About. Currently if you choose a company, you must choose a person from that company, and opportunity from that company also. We want to be able to choose any company, then any person from any company in the system, then choose any opportunity from the system and still allow the task to post to each company, person and opportunity. Would anyone have any suggestions on how to do this?

  • 0
    Hi,
    Rather than playing with behavior of standard fields, there can be a simpler approach for doing this. Check whether that works for you.

    1. Create two fields in Communication entity

    a. Related Person (Search Select Advanced on Person entity.)

    b. Related Opportunity(Search Select Advanced on Person entity.)

    2. Add these fields to Communications screen.

    3. Write table level script on communication entity and on PostInsert record method write a code for following.

    a. Copy current task against the Related person and company of that person using communication id in the context

    b. Copy current task against the Related Opportunity, its person and company using communication id in the context

    Note: What I mean by copying is clone the communication in communication table and comm_link in comm_link table using different Company, Person, Opportunity id parameters.

    Hope this workaround helps! Bit tricky but will retain the existing functionality. Anyways to create the tasks as per your scenario needs to be handled through code.
    Sincerely,
    Dinesh
  • 0

    Thank you this is exactly what I need, but i am having a problem.

    var intRecordId = CRM.GetContextInfo("communication","comm_communicationid");

    ErrorStr = "CommID:"+CRM.GetContextInfo("communication","comm_communicationid");

    var FirstRecord = CRM.FindRecord("communication","comm_communicationid="+intRecordId);

    var NewRecord = CRM.CreateRecord("communication");

    var FirstLinkRecord = CRM.FindRecord("comm_link","cmli_comm_communicationid="+intRecordId);

    var NewLinkRecord = CRM.CreateRecord("comm_link");

    //copy the data from the first record to the second

    e = new Enumerator(FirstRecord);

    while (e.item())

    {

    NewRecord(e.item()) = FirstRecord(e.item())

    e.moveNext();

    }

    //set the fields and properties unique to the new record

    NewRecord.Comm_OpportunityId = NewRecord.Comm_NewAbout;

    NewRecord.SaveChanges();

    //copy the data from the first record to the second

    e = new Enumerator(FirstLinkRecord);

    while (e.item())

    {

    NewLinkRecord(e.item()) = FirstLinkRecord(e.item())

    e.moveNext();

    }

    NewLinkRecord.comm_personid = NewLinkRecord.cmli_newPerson;

    NewLinkRecord.SaveChanges();

    CRM.GetContextInfo("communication","comm_communicationid") is not returning a value so I end up with a SQL error of...

    Incorrect syntax near the keyword 'AND' (select * from Communication WITH (NOLOCK) where comm_communicationid= AND comm_Deleted is null)

  • 0

    Replied with Problem Below.

  • 0

    I don't think you can use GetContextInfo in PostInsert to retrieve an id that has just been added - I think you have to use the Values() collection instead:

    var intRecordId = Values('comm_communicationid');

  • 0

    Excellent thank you. The problem now is that i am inserting a communication record in the AfterPost event, thus it is running after each insertion in a rather long loop and duplicating the tasks rather extensively. Any work around for this?

  • 0

    Actually I found that rather than inserting the record, I can just update that record and everything is working great. I did have to seperate the two and create one script for communications, and another for comm_link though. I also got this work when updating the records. Thank you all for your help.