Update record ID on library item - custom entity

I have created a library function for a custom entity(obligation) in CRM 7.1.d. The upload works fine and the record is created in either the opportunity library or the lead library, depending on which entity it belongs to.

I would like to use a table level script (or something similar) to update the libr_obligationid to the relevant record so that I can see the list of library items on the custom entity documents tab.

  • 0

    Hi,
    From the above forum I understand that you want to update libr_obligationid field in the Library table. To achieve this please follow below mentioned steps.

    1. The page (i.e.asp/.net) where you have written library function for custom entity(obligation), first you have to fetch the obligationid of the your record.

    2. Then before saving library record, assign obligationid to the libr_obligationid field and save the record.

    This way you can save the relevant record ids to the libr_obligationid.
    Hope this helps!
    Regards
    Dinesh

  • 0

    Hi Dinesh, that would be ideal, however I am not sure how to use the obligationid to save to the relevant record. The code is as follows:

    var sURL=new String( Request.ServerVariables("URL")() + "?" + Request.QueryString );

    var PersonKey = '';

    var CompanyKey = '';

    var OpportinityKey = '';

    var HasCommunication = '';

    Container=CRM.GetBlock("container");

    List=CRM.GetBlock("LibraryList");

    List.prevURL=sURL;

    var Id = new String(Request.Querystring("ledb_LeadDBID"));

    if (Id.toString() == 'undefined') {

    Id = new String(Request.Querystring("Key58"));

    }

    CRM.SetContext("LeadDB", Id);

    if (Id != 0 && ( false || false || true) ) {

    record = CRM.FindRecord("LeadDB", "ledb_LeadDBID=" + Id);

    if ( false )

    CompanyKey = "&Key" + iKey_CompanyId + "=" + record.Item("ledb_CompanyId");

    if ( false )

    PersonKey = "&Key" + iKey_PersonId + "=" + record.Item("ledb_PersonId");

    if ( true )

    OpportinityKey = "&Key" + iKey_OpportunityId + "=" + record.Item("ledb_OpportunityId");

    }

    if (false)

    {

    HasCommunication = "&MakeCommunicationYN=Y";

    }

    Container.AddBlock(List);

    if (ie_browser.toString() == "-1" ) {

    // The "FILEUPLOAD" string below is NOT a CAPTION - it is a constant to indicate to the COM object that a FILEUPLOAD button is expected

    Container.AddButton(CRM.Button("FILEUPLOAD", "FileUpload.gif", CRM.URL(343)+"&Key-1="+iKey_CustomEntity+PersonKey+CompanyKey+OpportinityKey+HasCommunication+"&PrevCustomURL="+List.prevURL+"&E=LeadDB"));

    }

    else

    {

    Container.AddButton(CRM.Button("FileUpload", "FileUpload.gif", CRM.URL(343)+"&Key-1="+iKey_CustomEntity+PersonKey+CompanyKey+OpportinityKey+HasCommunication+"&PrevCustomURL="+List.prevURL+"&E=LeadDB"));

    }

    Container.DisplayButton(1)=false;

    if (false){

    Container.AddButton(CRM.Button("ButtonMailMerge", "MailMerge.gif", CRM.URL(542)));

    }

    if( Id != '')

    {

    CRM.AddContent(Container.Execute("Libr_LeadDBId="+Id));

    }

    CRM.GetCustomEntityTopFrame("LeadDB");

    Response.Write(CRM.GetPage());

    - Any assistance would be appreciated.

  • 0
    Hi,
    From the above post it seems like the code which you have written is used to display the Library List Screen. We would appreciate if you can post the Library creation function.
    Regards,
    Dinesh
  • 0

    Hi Dinesh, it does both - it displays the list and the following line is the attachment button url:

    CRM.URL(343)+"&Key-1="+iKey_CustomEntity+PersonKey+CompanyKey+OpportinityKey+HasCommunication+"&PrevCustomURL="+List.prevURL+"&E=LeadDB"

    Then the attachment page is displayed.

  • 0

    Sorry it's not actually an obligationid but rather a leaddbid.

  • 0

    I've found that the attachment should be saving the parent id as well as the leaddb id. It works perfectly on my test system. The code is the same. When I run the SQL profiler I can see that the leaddb is not being passed and saved, whereas on my test system it is.

  • 0

    OK, I have found my error, I failed to place the id field on the document attachment screen therefore the id was not being passed to the record in the library.

    Many thanks.