Showing results for 
Search instead for 
Do you mean 
Community Home Request Access Read Blogs Share Your Ideas Search Community View My Settings
Reply
New Member
Posts: 2
Registered: ‎08-06-2010

Mail Merge to Opportunity Fields

I'm trying to perform a mail merge to opportunity fields.  In SLX Windows, I modified the VBScript Mail Merge OnCustomFieldName script to assist with this.  In Web, it's requesting I do the same thing when I try to merge a template.  I found the VBS file that it references but I don't know how to perform a lookup in VBS code so that I can get the value.  Has anyone else run into this or know how to perform a lookup from there?

 

Thanks!

 

TopLine Results

Dan Boehm

Silver Contributor
Posts: 1,262
Registered: ‎04-08-2009

Re: Mail Merge to Opportunity Fields

What do you mean with lookup?

The scripts for web and LAN work the same, so everything you do in the mail merge script in the LAN can be done in the web.

Keep in mind that in version 7.5.3 you will have a java script for the web version.

 

Alexander

New Member
Posts: 2
Registered: ‎08-06-2010

Re: Mail Merge to Opportunity Fields

When I refer to "lookup", I am referring to how we query the SQL database in the original Architect.  In the original Architect, I was using the objDB = New SLX_DB, objDB.GetNewRecordSet code.  I don't believe that this works in the Web version (maybe I'm wrong?).  So I'm looking for a way to query the database.  I have the OpportunityID and field name that I am looking for, I just need to know how to run a query.

 

Thanks!

Copper Elite Contributor
Posts: 39
Registered: ‎07-13-2010

Re: Mail Merge to Opportunity Fields

Could anybody tell me where I find the respective script which treats the custom mailmerge fields? What is its name of the script and where is it located? Thanks.

Copper Elite Contributor
Posts: 39
Registered: ‎07-13-2010

Re: Mail Merge to Opportunity Fields

[ Edited ]

I think I found it.

Seems to me it's sage-mailmerge-service.js (SLXClient\jscript)

I will try the function "HandleOnCustomFieldName" now - let's see.

Employee
Posts: 629
Registered: ‎04-24-2009

Re: Mail Merge to Opportunity Fields

There are some limitations when accessing the Word API through Desktop Integration when using JavaScript, most notably collections and properties in the Word object model that are defined as default properties often do not work. For example, you should use range.InsertAfter("SomeValue") instead of range.Text = "SomeValue" (.Text is a default property and will not work).

 

Thanks

 

Mike

Copper Elite Contributor
Posts: 39
Registered: ‎07-13-2010

Re: Mail Merge to Opportunity Fields

I think I need some help again.

I added a handling for my custom field to "sage-mailmerge-service.js" to the "HandleOnCustomFieldName" function.

 

case "Custom_Test":
  range.InsertAfter("my Test");
  break;

 

This field is added to the mailmerge templates, name spelling is correct.

When I now call the mailmerge document, I receive the folloging error message:

 

"The Mail Merge Engine encountered an error and cannot continue. There was an error processing the "Custom_Test" SLXSPECIAL_CUSTOM field. This field must be processed in a customized VBScript by the Sales Client. Please report this error to your SalesLogix Administrator: The custom merge field could not be processed because it was not handled in the OnCustomFieldName event."

 

It's SalesLogix version 7.5.4. Is the Javascript file I have tried to customize the wrong one and must I look for a VBScript file?

Silver Contributor
Posts: 1,262
Registered: ‎04-08-2009

Re: Mail Merge to Opportunity Fields

Hi. I think you need to re-build the sage-mailmerge.js file using js builder and the coresponding jsb file.

If you take a look at sage-mailmerge.js you will see that your custom field is not in there.

Just build the file and put it in the folder where the current file is in.

Thanks! Alexander

 

Employee
Posts: 629
Registered: ‎04-24-2009

Re: Mail Merge to Opportunity Fields

[ Edited ]

Yes, as Alexander noted below, you will have to rebuild sage-mailmerge.js. In addition, you can ignore the error message text in regard to MailMerge.vbs; the error message was not updated; this is a bug.

 

I've extracted the instructions for rebuilding sage-mailmerge.js from the "Applying Service Pack 3 for Sage SalesLogix Version 7.5".pdf.

 

<Quote>

Step 54

>snip<

 

Customizing the sage-mailmerge.js

 

If you have customized the MailMerge.vbs, any customizations that reference the original CreateObject calls must be replaced with the new Mail Merge API. The functionality formerly in the MailMerge.vbs script has been moved into sage-mailmerge-service.js and sage-mailmerge-loader.js.

 

The sage-mailmerge.js JavaScript implements the Sage.MailMergeService, Sage.SelectEmailInfo, Sage.CustomGroupExport, and Sage.ExcelExport JavaScript classes. The sage-mailmerge.js JavaScript, as well as its corresponding debug version (sage-mailmerge-debug.js), are generated files and should never be edited directly. These files can be regenerated using the third-party JS Builder application by opening and rebuilding the JS Builder Project file SageMailMerge.jsb, located in SlxClient\jscript. You can download the JS Builder application from http://code.google.com/p/js-builder/.

 

The source files included in the SageMailMerge.jsb JS Builder Project are:
• SlxClient\jscript\sage-mailmerge\ sage-mailmerge-service.js
• SlxClient\jscript\sage-mailmerge\ sage-mailmerge-context.js

 

Important

 

Sage highly recommends that you do not edit these source files directly. If these files are edited directly any subsequent upgrade process will be more complex and may introduce JavaScript errors or bugs.

 

To customize the JavaScript files

 

1. Create a new JavaScript file named sage-mailmerge-overrides.js.
2. Add sage-mailmerge-overrides.js to the existing SageMailMerge.jsb JS Builder Project file and save the project.
3. In JS Builder, open the Build Settings tab.
4. In the Combine compressed files to create specific output files section, select Sage Mail Merge, and then click Edit.
5. In the Output Target Properties dialog box, drag the sage-mailmerge-overrides.js from the list of Project Files to the bottom of the list of Included Files.
6. Click OK.
7. Rebuild the SageMailMerge.jsb in JS Builder.

 

When you rebuild the project the newly generated sage-mailmerge.js (and corresponding sage-mailmerge-debug.js) will include the appended content from sage-mailmerge-overrides.js at the end of these JavaScript files. When the Web browser loads the new sage-mailmerge.js JavaScript file, any overridden functions will automatically replace its original version.

</Quote>

 

You will want to copy the Sage.MailMergeService.prototype.HandleOnCustomFieldName function into your new sage-mailmerge-overrides.js and then follow the instructions above.

 

Thanks

 

Mike

Copper Elite Contributor
Posts: 39
Registered: ‎07-13-2010

Re: Mail Merge to Opportunity Fields

Now, I created a new file "sage-mailmerge-overrides.js" and copied the HandleOnCustomFieldName function into it, including my new customfield handling.

I did  a rebuild via the js builder and when I have a look at sage-mailmerge.js, I find the new code merged into it.

After this a did a deploy (checking the sage-mailmerge.js in the wwwroot folder and finding my customized code again in it), but unfortunatly, I still receive an error that my custom field is not treated in the respective script.

When I include "CUSTOMFIELDNAME_EXAMPLE_A" custom field in the template, everything works fine.

What am I doing wrong?