locked
CRM 4.0 - Populate nvarchar with GUID when record is created RRS feed

  • Question

  • Hi guys,

    Got a bit of an issue I was hoping someone could help resolve. I've got the code below on the OnSave event of opportunities. The idea being that when an opportunity is created, various workflow emails can be triggered with a link to the record contained in them.

    Having searched about, this seems to be a common problem, but I've not found a definitive solution. The problem is that when the record is created (and saved), the onsave code runs before the record is assigned a GUID. As such, nothing is populated in the new_oppurl field at that point - if the form is subsequently saved after creation the onsave code fires correctly and populates the field with the URL.

    Is there any way I can populate new_oppurl upon creation?

    if (crmForm.ObjectId !=null)
    {
    var guid=crmForm.ObjectId;
    guid=guid.substring(1,guid.length-1);
     crmForm.all.new_oppurl.DataValue='http://crm/ORGNAME/sfa/opps/edit.aspx?id=' + crmForm.ObjectId;
    }

    Tuesday, June 28, 2011 4:15 PM

Answers

  • You can use an onChange() of an attribute to save the record - first shot field would be null - second shot (user action) value won´t be null. Or you can just use the workflow utilities to get the url of the actual recordset and use a workflow to update your field with this value. Search for Business Produktivity Workflow


    Carsten Groth http://carstengroth.wordpress.com
    Tuesday, June 28, 2011 4:32 PM
  • Is there any reason why you are not using businessproductivity acclerator refer http://blogs.msdn.com/b/crm/archive/2008/10/01/crm-accelerators-part-viii-business-productivity-accelerator.aspx
    Mahain : My Dynamics CRM Blog
    • Marked as answer by wayneiles Thursday, June 30, 2011 1:18 PM
    Tuesday, June 28, 2011 4:36 PM
    Moderator

All replies

  • You can use an onChange() of an attribute to save the record - first shot field would be null - second shot (user action) value won´t be null. Or you can just use the workflow utilities to get the url of the actual recordset and use a workflow to update your field with this value. Search for Business Produktivity Workflow


    Carsten Groth http://carstengroth.wordpress.com
    Tuesday, June 28, 2011 4:32 PM
  • Is there any reason why you are not using businessproductivity acclerator refer http://blogs.msdn.com/b/crm/archive/2008/10/01/crm-accelerators-part-viii-business-productivity-accelerator.aspx
    Mahain : My Dynamics CRM Blog
    • Marked as answer by wayneiles Thursday, June 30, 2011 1:18 PM
    Tuesday, June 28, 2011 4:36 PM
    Moderator
  • Thanks guys - Businss Productivity Accelerator does the trick perfectly.
    Thursday, June 30, 2011 1:18 PM