7/8/2025 11:34:01 AM
|
|
slxdeveloper.com Community Forums |
|
|
|
The Forums on slxdeveloper.com are now retired. The forum archive will remain available for the time being. Thank you for your participation on slxdeveloper.com!
Forum to discuss writing script in Architect plugins for SalesLogix & general SalesLogix customization topics (for Windows client only). View the code of conduct for posting guidelines.
|
|
|
|
Change attachment output name during merge?
Posted: 29 Jan 08 12:49 PM
|
I was wondering if there is any way to change the description/filename of an attachment when using the write - letter menu option? I've created a custom method in the system OnCustomFieldName script to handle the auto-generation & logging of quote numbers. To make the quote # more visible I'd like to add it to the attachment description automatically, so it appears as "Quote - #9210018" in the attachments tab (and perhaps in the actual documents filename).
Is this even possible? |
|
|
| |
|
Re: Change attachment output name during merge?
Posted: 29 Jan 08 1:37 PM
|
Well don't that just figger. I don't suppose there is a way to pass a value through to the "Complete Document" window? I noticed that it carries the document description into the regarding field.
A long shot, but man that'd be slick. |
|
|
|
Re: Change attachment output name during merge?
Posted: 29 Jan 08 1:43 PM
|
'Nope - however, the MM SDK gives you much more control over naming etc. It's actually really really easy to do - and you can pop the lot onto a button or something so the users just press a single button. |
|
|
|
Re: Change attachment output name during merge?
Posted: 30 Jan 08 8:37 AM
|
I ran into the same situation a few months back. As mentioned by others, the MM properties do not allow you to assign an attachment name. I resorted to the below SQL statement, pending a successful MM, that has been 100% effective thus far.
strSQL = "UPDATE Attachment SET Description = 'Quote - " & strQuoteNum & "'" & _ " WHERE OpportunityID = '" & Application.BasicFunctions.CurrentOpportunityID & "'" & _ " AND UserID = '" & strUserID & "'" & _ " AND Description = '" & strAttachmentDescription & "'" & _ " AND DATEDIFF(mi, AttachDate, GETDATE()) < 10"
On another note, it may not be feasible to catch all MM errors via the OnCustomFieldName script. There's documentation floating around that shows you how to access MM functionality. If you haven't yet seen it, an example is provided below.
Sub MergeQuote (strTemplateID, strOldMonth, intOldSeqNum, strOldQuoteNum, strUserID)
'****************************************** ' This sub contains only a subset of the ' MailMerge functionality. Many standard ' items have been omitted for brevity. '****************************************** On Error Resume Next
' AttachmentType Const atRegularAttachment = 0 ' Default Const atLibraryAttachment = 1 Const atTempAttachment = 2
' FollowUp Const fuNone = 0 ' Default Const fuMeeting = 1 Const fuPhoneCall = 2 Const fuToDo = 3
' GroupFamily Const famContact = 0 ' Default Const famAccount = 1 Const famOpportunity = 2
' MergeWith Const withCurrentContact = 0 Const withCurrentGroup = 1 Const withSpecificGroup = 2 Const withAccount = 3 Const withOpportunity = 4 Const withContactIDs = 5 ' Default
' OutputType 'Const otPrinter = 0 Const otFile = 1 'Const otEmail = 2 ' Default 'Const otFax = 3
Dim oSLXDocument Dim oFSO Dim oFile Dim vFileName Dim vLibraryPath Dim vSecondsPerDay Dim vDateTime Dim vDuration
' This file will be deleted if the merge is successful. It's a temporary file only. If there ' were errors this file may remain (e.g. when the engine doesn't get called), so delete it ' if it is found.
vFileName = "C:\QuoteTemp.sdd"
Set oFSO = CreateObject("Scripting.FileSystemObject")
If ErrorCheck("There was an error creating the Scripting.FileSystemOject object.") Then Exit Sub
If oFSO.FileExists(vFileName) Then Set oFile = oFSO.GetFile(vFileName) oFile.Delete() End If
Set oFile = Nothing Set oFSO = Nothing
If ErrorCheck("There was an error using the Scripting.FileSystemOject object.") Then Exit Sub
Set oSLXDocument = CreateObject("SLXDoc.SLXDocument")
If ErrorCheck("Error creating the SalesLogix Document Description object.") Then Exit Sub
If oSLXDocument.CreateNew(vFileName) Then ' --------------------------------------------------------------------------------------------- ' Base options ' Set internally based on system settings ' oSLXDocument.MailMergeInformation.AttachmentPath = "" ' oSLXDocument.MailMergeInformation.BaseKeyCode = "" ' oSLXDocument.MailMergeInformation.BaseTable = "" ' oSLXDocument.MailMergeInformation.ConnectionString = "" ' oSLXDocument.MailMergeInformation.Remote = "" ' oSLXDocument.MailMergeInformation.SiteCode = "" ' oSLXDocument.MailMergeInformation.TransportType = transNative ' oSLXDocument.MailMergeInformation.UserID = ""
' True to attach the merged document to the contact ' ***Was true oSLXDocument.MailMergeInformation.DoAttachments = True
' True to use contact's solicitation options (DONOTSOLICT, DONOTEMAIL, DONOTFAX, etc.) oSLXDocument.MailMergeInformation.DoNotSolicit = False
' If MergeSilently is True and EditAfter is True there will be an error ' since EditAfter requires interation with the UI. oSLXDocument.MailMergeInformation.EditAfter = True
' If MergeSilently is True and EditBefore is True there will be an error ' since EditBefore requires interation with the UI. oSLXDocument.MailMergeInformation.EditBefore = False
' MergeSilently is currently forced to False internally. It will be fixed in SalesLogix 6.1. oSLXDocument.MailMergeInformation.MergeSilently = False
' --------------------------------------------------------------------------------------------- ' The type of merge output: otPrinter, otFile, otEmail, or otFax. 'oSLXDocument.MailMergeInformation.OutputTo = otEmail 'oSLXDocument.MailMergeInformation.OutputTo = otPrinter oSLXDocument.MailMergeInformation.OutputTo = otFile 'oSLXDocument.MailMergeInformation.OutputTo = otFax
' --------------------------------------------------------------------------------------------- ' A type 25 plugin ID (Microsoft Word template) oSLXDocument.MailMergeInformation.TemplatePluginID = strTemplateID
' FileDirectory is used for an OutputTo of otFile ' GetPersonalDataPath = 'C:\Documents and Settings\%User%\My Documents\SalesLogix'. oSLXDocument.MailMergeInformation.FileDirectory = Application.BasicFunctions.GetPersonalDataPath
' Label options oSLXDocument.MailMergeInformation.DoPrintLabels = False
' --------------------------------------------------------------------------------------------- ' MergeWith defines what entity type property the engine should use when merging ' (i.e. AccountID, OpportuntiyID, CurrentContactID, GroupID, or ContactIDs) 'oSLXDocument.MailMergeInformation.MergeWith = withCurrentContact 'oSLXDocument.MailMergeInformation.MergeWith = withSpecificGroup 'oSLXDocument.MailMergeInformation.MergeWith = withAccount oSLXDocument.MailMergeInformation.MergeWith = withOpportunity 'oSLXDocument.MailMergeInformation.MergeWith = withContactIDs
Select Case oSLXDocument.MailMergeInformation.MergeWith Case withCurrentContact oSLXDocument.MailMergeInformation.CurrentContactID = "CGHEA0002670" oSLXDocument.MailMergeInformation.CurrentContactName = "John Abbott" ' not required
Case withCurrentGroup, withSpecificGroup oSLXDocument.MailMergeInformation.GroupID = "GROUP0ALLACC" oSLXDocument.MailMergeInformation.GroupName = "All Accounts" ' not required oSLXDocument.MailMergeInformation.GroupFamily = famAccount ' not required'
Case withAccount oSLXDocument.MailMergeInformation.AccountID = "AGHEA0002669" oSLXDocument.MailMergeInformation.AccountName = "Abbott Ltd." ' not required
Case withOpportunity oSLXDocument.MailMergeInformation.OpportunityID = Application.BasicFunctions.CurrentOpportunityID oSLXDocument.MailMergeInformation.OpportunityName = GetField("Description", "Opportunity", "OpportunityID = '" & Application.BasicFunctions.CurrentOpportunityID & "'")
Case withContactIDs ' ContactIDs is a comma-delimited list of contact IDs. ' "Jim Berghold", "John Contorno", and "Willis Wilsey". oSLXDocument.MailMergeInformation.ContactIDs = "CA2EK0013116,CA2EK0013117,CA2EK0013118" End Select
' --------------------------------------------------------------------------------------------- ' History options oSLXDocument.MailMergeInformation.DoHistory = False
' Schedule Follow-Up options are used when DoScheduleFollowUp is True oSLXDocument.MailMergeInformation.DoScheduleFollowUp = False
' --------------------------------------------------------------------------------------------- Dim strAuthorName
strAuthorName = GetField("FirstName", "UserInfo", "UserID = '" & strUserID & "'") strAuthorName = strAuthorName & " " & GetField("LastName", "UserInfo", "UserID = '" & strUserID & "'")
' Summary Info (not required) oSLXDocument.SummaryInformation.Author = strAuthorName oSLXDocument.SummaryInformation.Title = "Quote"
' --------------------------------------------------------------------------------------------- ' Commit the changes to the oSLXDocument oSLXDocument.Commit()
' --------------------------------------------------------------------------------------------- ' Close the oSLXDocument oSLXDocument.Close()
' --------------------------------------------------------------------------------------------- Set oSLXDocument = Nothing
' ---------------------------------------------------------------------------------------------
' Run the merge job If Not Application.BasicFunctions.MergeFromFile(vFileName) Then MsgBox "MergeFromFile failed or was canceled." 'Merge Failed; revert back to old quote RevertQuote strOldMonth, intOldSeqNum, strOldQuoteNum, strUserID End If |
|
|
|
Re: Change attachment output name during merge?
Posted: 30 Jan 08 8:50 AM
|
Thanks for the insight Chris... Your method for altering the attachment description is intriguing, however knowing the sales guys here I can't guarantee it will adjust the description correctly 100% of the time (they are likely to cancel/redo multiple times). I think in the interim I will teach them the way of SpeedSearch so they can locate the quote # from inside the document, for the few times its necessary.
For the MergeQuote procedure I haven't seen any documentation on this yet... Is this a custom sub or is it something that's actually buried in a plugin somewhere? I assume it's custom? |
|
|
|
Re: Change attachment output name during merge?
Posted: 30 Jan 08 9:36 AM
|
You can download the document here: http://www.slxdeveloper.com/page.aspx?id=35&articleid=85 The last I read, the Mail Merge object(s) is "unsupported" by Sage Software.
I understand your concern over the salespeople. To minimize the risk, I added code that reverts the quote number back upon error or cancellation. I also maintain the quote sequence independent for each salesperson along with incorporating a unique identifier within the quote # to identify the salesperson. Additionally, as part of a good business process, I tell salespeople to generate an new quote and quote # anytime that a quote is modified. After all, it is just a number. By having a unique identifier for each quote number, this helps ensure that the salesperson and the customer are referencing the same products, prices, terms, etc. when referencing a quote/opportunity. Also, it's easy to reference the Opportunity:Attachments tab to view the evolution of the sales opportunity. As one final note, you can also code your quoting interface such that every possible element (with maybe the exception of minor formatting) is modified in the opportunity. I've had great success in building tools around the opportunity for custom product descriptions, global discounting, misc products, terms & conditions, etc. that give salespeople no need to modify the quote directly. This helps enforce the notion that salespeople should maintain the opportunity not word documents. In some roundabout way, all of this helps structure the workflow and reduce issues with renaming attachments. At either rate, it is a crude workaround. It would be nice if Sage would add a property for filename. |
|
|
|
Re: Change attachment output name during merge?
Posted: 30 Jan 08 9:58 AM
|
Wow, I've got my work cut out for me. Thanks for the link & the info again Chris, I think building more of the quote properties into the opportunity is the way to go. I've got an SLX refresher/brainstorm meeting on Monday with the owner & sales team, I'll bring it up and see if they want some time devoted to this.
Thanks again! |
|
|
|
Re: Change attachment output name during merge?
Posted: 23 Feb 10 6:26 PM
|
Hi,
Has this changed with 7.x? Is it possible to rename the file created? Or do I need to rename/move the file after it is generated? I'm using a custom attachment table so I am not saving the standar attachment and history record.
Thx, Leon |
|
|
|
You can
subscribe to receive a daily forum digest in your
user profile. View the site code
of conduct for posting guidelines.
Forum RSS Feed - Subscribe to the forum RSS feed to keep on top of the latest forum activity!
|
|
|
|
|
|
|
|