ATC: SET tablename.fieldname = value

This command sets a specified field on the current document to the value specified.

  • tablename is optional; however, if it is omitted, the Document Header (DocMasterDetail) is assumed. It specifies the target of the assignment. You can use @ to reference the current row in a FOREACH loop, or TargetRow to reference a recent row manipulated by another command such as ATC: ADD COMMENT or ATC: ADD ITEM.
  • . (period) is required only if tablename is specified. It separates tablename from the fieldname.
  • fieldname is required. It specifies the field in tablename to receive the value or—if tablename was omitted and fieldname begins with a $—the name of a local variable.
  • = (equal sign) is required.
  • value is required. The value can be any of the following:
    • @.fieldname specifies a value from a field in the current row of the FOREACH loop
    • TargetRow.fieldname specifies a value from a field in the current TargetRow
    • tablename.fieldname specifies a value from a field in the source document
    • # (number sign) has special meaning when used with DocNo: indicates that the document number should be reassigned to the next available value during the next save.
    • * (asterisk) indicates that the value should be copied from the source document.
    • EMPTY sets the field to blank/empty.
    • NULL indicates a NULL value for the field.
    • [V23+] BeforeChange( tablename.field ) returns the value of the field prior to the pending change. This only makes sense after an IsChanging test. Note: The space after the open parenthesis is required!
    • [V23+] Compute( tablename, expression [,filter] ) returns the expression evaluated for all rows in the specified table, or those rows that match the optional filter.  All three parameters can be a variable, bookmark or string constant.  Expression and Filter must conform to the syntax for .NET Data Expressions.  Note the space after the open parenthesis: it helps the parser and is essential if any periods appear in the expression or filter.
    • Concatenate( value,value [,…,value) returns the concatenation off all the values, each of which can be a variable or bookmark or string constant.  Note the space after the open parenthesis: it helps the parser and is essential if any of the concatenated segments includes a period.   Commas as well as leading and trailing white spaces are removed from the segments, so include:
      • \b for a space
      • \c for a comma
      • \n for a new line
    • FormatResult (value, format ) returns the value formatted as specified
      • Numeric formats, including (for example) N0, C2, F1, P3, # and 0
      • Date formats (see .NET specification)
      • Mask formats (for example Kxxx-xx-xxxx)
    • LookupResult (dvname, value, dependson1, dependson2, dependson3) returns a value based on a scalar lookup (sort of like the Microsoft Excel VLookup function). See an example below.
      • dvname is the name of a lookup result. See the Lookup Result Validation Names section of  KBA-01535.
      • value is the value to look up, either a bookmark or a variable.
      • dependson1-3 are all optional and provide input values, either as bookmarks or variables
    • NOW() specifies that the current date and time should be used.
      • +n.n can follow NOW() to add a number of days (with decimal) to the current date.
    • new value specifies the value to be stored for the field.
      • [bookmark] specifies a Word Template bookmark. The square brackets are required.

Examples

ATC: SET SourceContact = *

The above example means “set the field SourceContact in DocMasterDetail equal to the value of the same field in the source document.”

ATC: SET ResponsibleParty = [DKEY_DocHeader_EditUser]

The above example means “set the field ResponsibleParty in DocMasterDetail equal to the value of the current user working with the document.”  Effectively, this makes the current user the Responsible Party.

ATC: SET DocNo = #

The above example means “reassign the doc number to the next available document number when the document is saved.”

ATC: SET DocRevision.Title = Notification

The above example means “set the value of the field Title in the table DocRevision equal to Notification. [See also the example for ATC: ENDLOOP.]

ATC: SET DocDate = NOW()+1

The example above means “set the document’s date to tomorrow.”

ATC: SET DocRevision.NoteA = EMPTY

The example above means “blank out the second notes field on the document’s Note tab.”

ATC: SET $Status = [DocHeader_Status]

The example above means “store the status in $Status.”

ATC: SET $V = DocMasterDetail.SourceDocNo
ATC: SET $F = #,000
ATC: SET SourceDocNo = FormatResult( $V, $F )
The example above means "place a field value into $V and a format into $F, then format the value and place it into SourceDocNo".

ATC: IF DocRevision.csString016 IsChanging 
ATC: SET $SCDMK = LookupResult(SubcontractDocMaster, [DocRevision_csString016], [DocHeader_Project]) 
ATC: IF $SCDMK != EMPTY 
ATC: SET SourceContact = LookupResult( DocSourceContact, $SCDMK) 
ATC: ENDIF 
ATC: ENDIF

The example above means “if the value in csString016 has changed, look up the Commitment document with the value in csString016 for the same project.  Take the key (for the Commitment) returned and look up the key of the vendor.”

ATC: IF Subcontract IsChanging
    ATC: EXIT WHEN Subcontract IsEmpty
    ATC: SET $SCDMK = LookupResult( SubcontractDocMaster, [DocHeader_Subcontract], [DocHeader_Project])
    ATC: GET KEY $SCDMK; WITH BookmarkSource
    ATC: SELECT SOURCE
    ATC: SET PayItemNumber = [DocHeader_PayItemNumber]
    ATC: BookmarkSource SOURCE
ATC: ENDIF

The above example means “when the Subcontract field on the source document has changed, do the following: look up the specific Subcontract document on the project and hold its DataPK in a variable, then use the bookmarks from that document to copy from, specifically setting the PayItemNumber field on the source document to equal the PayItemNumber on the copy from document. Finally, make the source document the source for bookmarks.”

ATC: SET $V = DocHeader.SourceDocNo
ATC: SET $Exp = Concatenate( $V, + 1)
ATC: SET SourceDocNo = COMPUTE( DocHeader, $Exp)

The above example means “place the current value of the SourceDocNo field into the variable $V and then concatenate that value with + 1.  Then assign the computed expression back into the SourceDocNo field. The net effect will be to increment the SourceDocNo field (as long as the field is empty or numeric).

ATC: EXIT HasNot DocItem WITH true;
ATC: EXIT WHEN NOT CLOSED IsEmpty
ATC: SET $GLSA = 102000000
ATC: FOREACH DOCITEMTASK BY DocItemKey WITH GLSUB IS NULL OR GLSUB = '';
    ATC: IF @.GLSUB IsEmpty
        ATC: SET @.GLSUB = $GLSA
    ATC: ENDIF
ATC: ENDLOOP

The above example means “leave this workflow if the document does not have Items or is closed; otherwise, create a variable to hold GL Account #102000000, then for each Item that does not have a GL Account, enter 102000000 as the GL Account.”


Last updated: September 18, 2024 at 11:41 am;  green text = new