Help with Merge to Word Coding

SOLVED

Hi.

I'm using this code to display a Merge to Word button within an ASP file:

if( CRM.Mode == 2) {
if(true){
searchContainer.AddButton(CRM.Button("ButtonMailMerge", "NewDoc.gif", "javascript:document.EntryForm.TargetAction.value = 'NewWordDocument'; document.EntryForm.submit();"));
}

However, its not working quite right when it comes to storing the mail merge it within the companies' communication that follows.An unexpected event has occurred: EOleException: Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.

I think it has to do with the Button. But I'm not 100% sure. 
Can someone let me know if the coding above is legit for Sage CRM v2018r3?

Thanks,

Stephan

Parents
  • +1
    verified answer

    You can find example code within the XXXXXLibrary.asp page that the Advanced Customization Wizard generates.

    var caption = "FileUpload";
    // The "FILEUPLOAD" string below is NOT  a CAPTION - it is a constant to indicate to the COM object that a FILEUPLOAD button is expected
    caption = "FILEUPLOAD";
    Container.AddButton(CRM.Button(caption, "FileUpload.gif", CRM.URL(343)+"&Key-1="+iKey_CustomEntity+PersonKey+CompanyKey+OpportinityKey+HasCommunication+"&PrevCustomURL="+List.prevURL+"&E=Project"));

    Container.DisplayButton(1)=false;
    if (true){
      Container.AddButton(CRM.Button("MergeToWord", "MailMergeDOC.gif", CRM.URL(542)));
      Container.AddButton(CRM.Button("MergeToPDF", "MailMergePDF.gif", CRM.URL(6101)));
    }
  • +1 in reply to Sage CRM
    verified answer

    Hi.

    I think I found the issue I'm having.
    It has to do with the &Key0=58

    This needs to be &Key0=19 instead.

    How do I make this change with the following code:"javascript:document.EntryForm.TargetAction.value = 'NewWordDocument'; document.EntryForm.submit();")); 

    Or with this code:searchContainer.AddButton(CRM.Button("MergeToWord", "MailMergeDOC.gif", CRM.URL(542)));

    Let me know.

    Thanks,

    Stephan

Reply
  • +1 in reply to Sage CRM
    verified answer

    Hi.

    I think I found the issue I'm having.
    It has to do with the &Key0=58

    This needs to be &Key0=19 instead.

    How do I make this change with the following code:"javascript:document.EntryForm.TargetAction.value = 'NewWordDocument'; document.EntryForm.submit();")); 

    Or with this code:searchContainer.AddButton(CRM.Button("MergeToWord", "MailMergeDOC.gif", CRM.URL(542)));

    Let me know.

    Thanks,

    Stephan

Children