SaveTextTemplate

Creates a new journal template, or updates an existing journal template.

Caution!

To successfully call SaveTextTemplate, the connected user must be assigned to the Journals Administrator role.

The arguments for template line items consist of arrays. The arrays have a one-to-one correspondence; for example, the second elements in the varabstrAmount and vararlAccount arguments’ arrays specify the amount and account for a template’s second line item.

SaveTextTemplate takes a String array for the template’s line item’s amounts. To create a template by passing a Double array of amounts, use SaveTemplate instead of SaveTextTemplate. The methods are almost identical; the only difference is the subtype of the line item amount array. For more information, see SaveTemplate.

Syntax

<IHsvJournalsEx>.SaveTextTemplate nType, nAttribute, bstrLabel, bstrDescription, bstrGroup, lSingleEntity, lSingleParent, nTemplateType, lValueID, vararnDebitCreditUnit, varabstrAmount, vararbstrDescription, vararlEntity, vararlParent, vararlAccount, vararlICP, vararlCustom1, vararlCustom2, vararlCustom3, vararlCustom4, plTemplateID

Argument

Description

nType

Integer (ByVal). Specifies the journal type of the journals that will be created from the template. Pass one of the HFMConstants type library constants listed in Journal Type Constants.

nAttribute

Integer (ByVal). Specifies whether journals created from the template must be balanced. Pass one of the HFMConstants type library constants listed in Balance Type Constants.

bstrLabel

String (ByVal). The label of the template.

bstrDescription

String (ByVal). The description for the template. You can pass a blank string if there is no description.

bstrGroup

String (ByVal). The journal group to which the journals created from the template will be assigned. You can pass a blank string if the journals will not be assigned to a journal group

lSecurityClass

Long. The ID of the security class for the template.

Tip:

To get the ID from a security class name, use HsvSecurityAccess.GetSecurityClassLabel.

lSingleEntity

Long (ByVal). For single entity journal templates, specify the member ID of the journal’s base entity. For multi-entity journal templates, pass a value of -1.

lSingleParent

Long (ByVal). For single entity journal templates, specify the member ID of the journal’s parent entity. For multi-entity journal templates, pass a value of -1.

nTemplateType

Integer (ByVal). Determines whether the template is standard or recurring. Pass one of the HFMConstants type library constants listed in Template Type Constants.

lValueID

Long (ByVal). For recurring templates, specify the member ID of the template’s Value dimension member.

Since standard templates are not assigned a Value dimension member, this argument returns -1 when GetTemplate is called for a standard template.

vararnDebitCreditUnit

Integer array (ByVal). Specifies whether the line items are debits or credits. Pass one of the HFMConstants type library constants listed in Debit/Credit Constants.

varabstrAmount

String array (ByVal). The amounts of the line items.

vararbstrDescription

String array (ByVal). The descriptions of the line items.

vararlEntity

Long array (ByVal). The member IDs for the base entities of the line items. For single-entity items, set the IDs in this array to the same member ID that is in the lSingleEntity argument.

vararlParent

Long array (ByVal). The member IDs for the parent entities of the line items. For single-entity items, set the IDs in this array to the same member ID that is in the lSingleParent argument.

vararlAccount

Long array (ByVal). The member IDs of the accounts for the line items.

vararlICP

Long array (ByVal). The member IDs of the line items’ Intercompany Partner dimension members.

vararlCustom1

Long array (ByVal). The member IDs of the line items’ Custom 1 dimension members.

vararlCustom2

Long array (ByVal). The member IDs of the line items’ Custom 2 dimension members.

vararlCustom3

Long array (ByVal). The member IDs of the line items’ Custom 3 dimension members.

vararlCustom4

Long array (ByVal). The member IDs of the line items’ Custom 4 dimension members.

plTemplateID

Long. The purpose of this argument depends upon whether you are creating a new template or updating an existing template:

  • For a newly created template, this argument returns the automatically-generated ID of the template.

  • To update an existing template, pass the template’s ID with this argument. You can get template IDs with GetJournalTemplateItemID; for details, see GetJournalTemplateItemID.

Example

This example defines a custom function named NewTextTemplate that creates new templates from an existing template, changing the entities while carrying over the other properties of the existing template. The existing template’s name and the new template’s name, description, and Entity dimension member IDs are passed as the custom function’s arguments. The example calls GetTextTemplate to get the existing template’s information.

Function NewTextTemplate(sTemplate As String, sNewLabel _
   As String, sDesc As String, lNewEntID As Long, _
   lNewParID As Long) As Long
Dim cHsvJournals As HsvJournals, iType As Integer
Dim cIHsvJournalEx As IHsvJournalsEx, lTempID As Long
Dim sLabel As String, sDescHead As String, sGroup As String
Dim lSecID As Long, lSingleEnt As Long, lSinglePar As Long
Dim iTempType As Integer, lVal As Long, vaEntryIDs
Dim vaDebCredUnit, vaAmt, vaItemDesc, vaEnt, vaPar, vaAcct
Dim vaICP, vaCust1, vaCust2, vaCust3, vaCust4
Dim lNewTempID As Long, iAttr As Integer, laNewEnt() As Long
Dim laNewPar() As Long, lUpBounds As Long
'm_cSession is an HsvSession object reference
Set cHsvJournals = m_cSession.Journals
Set cIHsvJournalEx = m_cSession.Journals
lTempID = cHsvJournals.GetJournalTemplateItemID(sTemplate)
cIHsvJournalEx.GetTextTemplate lTempID, iType, iAttr, sLabel, _
   sDescHead, sGroup, lSecID, lSingleEnt, lSinglePar, _
   iTempType, lVal, vaEntryIDs, vaDebCredUnit, vaAmt, _
   vaItemDesc, vaEnt, vaPar, vaAcct, vaICP, vaCust1, vaCust2, _
   vaCust3, vaCust4
   lUpBounds = UBound(vaEnt)
'Create the entity ID arrays that will be passed to SaveTemplate
ReDim laNewEnt(lUpBounds)
ReDim laNewPar(lUpBounds)
For i = LBound(vaEnt) To lUpBounds
   laNewEnt(i) = lNewEntID
   laNewPar(i) = lNewParID
Next i
cIHsvJournalEx.SaveTextTemplate iType, iAttr, sNewLabel, _
   sDesc, sGroup, lSecID, lNewEntID, lNewParID, iTempType, _
   lVal, vaDebCredUnit, vaAmt, vaItemDesc, laNewEnt, _
   laNewPar, vaAcct, vaICP, vaCust1, vaCust2, vaCust3, _
   vaCust4, lNewTempID
NewTextTemplate = lNewTempID
End Function