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:
- new value specifies the value to be stored for the field.
- @.fieldname a value from a field in the current row of the FOREACH loop
- TargetRow.fieldname a value from a field in the current TargetRow
- tablename.fieldname a value from a field in the source document
- [bookmark] specifies a Word Template bookmark. The square brackets are required.
- # (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.
- 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. Leading and trailing spaces are removed from the segments.
- 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.
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.”
Last updated: June 29, 2022 at 16:19 pm; green text = new