ATC: QUERY qalias d1 d2 d3

This command runs the query dynamically defined through a QueryConfig | qalias:Alias rule. The result set is thus available for other ATC commands in the workflow

  • qalias is required. This query name must match the qalias in the QueryConfig | qalias:Alias rule.
  • d1-d3 are optional. Each specifies an additional parameter value.  The values are space delimited;  with 2019.0.7296 and later, you can specify bookmarks or variables and spaces in the expanded bookmark or variable are preserved.

After the query, $$RowCount is set to the number of rows returned and you can also refer to the alias-name in FOREACH and other commands.

Examples

ATC:QUERY qPOLIST
ATC:FOREACH qPOLIST
     ATC:IF @.DUE < NOW()
          ATC: IF @.Received = NULL
               ATC:COPY [Material Tracking] * NEW; WITH LINK
               ATC: SET Title = @.Title
               ATC: SET Priority = 1
               ATC: SET SourceDocNo = @.DocNo
               ATC: SAVE
               ATC: SELECT SOURCE
          ATC:ENDIF
     ATC: ENDIF
ATC:ENDLOOP

The above example means “use the qPOLIST alias (defined in the qPOLIST:Alias rule) and then, for all the materials returned by the qPOLIST query, check if any have a Due date past Now and if the Received field is empty. If so, create a new document of the Material Tracking Doc type in the same project as the current document and link the new document to the source document as an attachment; then set the Title to match the material, set the Priority to High and set the SourceDocNo to the PO Commitment number. Save then return context to the source document.”

ATC: IF DocDate IsChanging
   ATC: QUERY qFP [FyyyyxMMxdd_docheader_docdate]
   ATC: SET DocRevision.InPeriod = [qFP_FP]
ATC: ENDIF

The above example means “if the document date has changed, pass the date to the FP qAlias and store the fiscal period”

ATC: IF Title IsChanging
   ATC: SET $NewTitle = DocHeader.Title
   ATC: QUERY qExample $NewTitle [Docheader_DocNo]
   ATC: SET DocRevision.NoteA = qExample.result
ATC: ENDIF

The above example means “if the document title has changed, pass the title to the variable called $NewTitle then set the qAlias called qExample to both the title and Doc number and store that result into NoteA on the document.”

ATC: SETHTML $Body = Change Order Request Submitted 
ATC: SET STATUS = S 
ATC: ADD UIA QueueCloseDocWindow 2 
ACT: QUERY qRoleMembers 
ATC: SEND TO qRoleMembers.UserKey 
     SUBJ [DV_DocHeader_DocTypeKey] - [DocHeader_SourceDocNo] - [DocHeader_Title]; 
     BODY $Body

The above example means “store a message into $Body, set the document status to S, tell the document window to close.  It runs a query to determine project team role members (qRoleMembers) and Sends and email to those people”

Requires QueryConfig rules:

  • QueryConfig | qRoleMembers:qAlias =
SELECT * FROM dbo.vsf_ProjectTeamResponsibility t 
WHERE t.project = @pProject and t.RoleName LIKE @pD1;
  • QueryConfig | qRoleMembers:qPList = @pD1

Last updated: June 17, 2022 at 16:23 pm;