locked
Problem when filling regardingobjectid from plug-in RRS feed

  • Question

  • Hello everyone,

    I created a pre-operation plug-in in CRM 2013, which automatically creates a quote from a phonecall entity if the necessary fields are set. After the quote is created, I set the regardingobjectid field to the newly created quote. My problem is that the regarding field is not working in my case as it should. The change does not show up on the regarding field, it still shows empty value. However, if I click on the field, the quote icon is shown, but not the name property next to it. Clicking on the field again does redirect me to the quote form as expected, which is populated correctly, including quote name.

    This is part of my code, any ideas?

    Entity quote = new Entity("quote");
    quote["customerid"] = toRecordRef;                    
    quote["transactioncurrencyid"] = currencyRef;
    Entity product = productRef != null ? service.Retrieve(productRef.LogicalName, productRef.Id, new ColumnSet("pricelevelid", "defaultuomid", "name")) : null;
    quote["pricelevelid"] = product != null ? product["pricelevelid"] : null;
    quote["name"] = product != null ? product["name"].ToString() + " - " + DateTime.Now.ToString("yyyy.MM.dd") : DateTime.Now.ToString("yyyy.MM.dd");
    Guid quoteid = service.Create(quote);
    
    entity["regardingobjectid"] = new EntityReference("quote", quoteid);


    • Edited by Adam Borsik Monday, March 31, 2014 10:58 AM spelling error
    Monday, March 31, 2014 10:57 AM

Answers

  • Might be a weirdness with the regular EntityReference not having the display name populated, typically it's not a problem but try this:

    EntityReference quoteRef = new EntityReference("quote", quoteid);

    quoteRef.Name = (string)quote["name"];

    entity["regardingobjectid"] = quoteRef;


    • Marked as answer by Adam Borsik Tuesday, April 1, 2014 6:48 AM
    Tuesday, April 1, 2014 12:25 AM