0
Assume a function like:
def Import_PDF_Data(pbr_Item , str_Fname) {
...
}
It may be passed a newly created Project Based Record item:
var pbr = Ext.CreateProjectBasedRecord( n_My_Primary_TableID ) ;
Import_PDF_Data(pbr , "... some path ...") ;
or it may be passed and item, possibly the current item, which was previously submitted.
Import_PDF_Data(Shell.Item , "... some path ...") ;


Is it possible for the function to quickly & easily detect the difference between the newly instantiated PBR and one that had been previously submitted?? I could check for previous transitions in the ChangeActions table, but that doesn't seem real speedy.

Fallback is to add a flag to the function's params that indicates "new item" / "one that's been around the block".

Accepted Answer

Tuesday, June 11 2019, 10:12 AM - #Permalink
1
In a SUBMIT transition, Shell.Item will have a valid TS_ID and TS_ISSUEID. TS_UUID will be blank. In the newly created database record for the item, TS_ID will be 0 and TS_ISSUEID and TS_UUID will be blank.

To read the DB record I create an AppRecord and read the Record ID from Shell.Item.GetId, then use GetFieldValue("issueid") to read TS_ISSUEID, GetId to read TS_ID and GetUUID to read TS_UUID. By using my own AppRecord, I avoid the caching and value initialization done by SBM for Shell.Item.

Note that you can't use the GetFieldValue() function to read TS_ID or TS_UUID -- you have to used the dedicated functions GetId and GetUUID:

var arec_Db = Ext.AppRecord( Shell.Item.GetRecTableId ) ;
var n_Id = Shell.Item.GetId ;
var str_IssueId = "" ;
var str_UUID="" ;

arec_Db.Read(n_Id);

n_Id = arec_Db.GetId ;
str_IssueId = arec_Db.GetFieldValue("issueid") ;
str_UUID = arec_Db.GetUUID ;


return (n_Id==0 && str_IssueId.size==0 && str_UUID.size==0) ;
The reply is currently minimized Show
Responses (1)
  • Accepted Answer

    Tuesday, June 18 2019, 06:57 AM - #Permalink
    0
    How
    Paul Thompson wrote:

    Assume a function like:
    def Import_PDF_Data(pbr_Item , str_Fname) {
    ...
    }
    It may be passed a newly created Project Based Record item:
    var pbr = Ext.CreateProjectBasedRecord( n_My_Primary_TableID ) ;
    Import_PDF_Data(pbr , "... some path ...") ;
    or it may be passed and item, possibly the current item, which was previously submitted.
    Import_PDF_Data(Shell.Item , "... some path ...") ;


    Is it possible for the function to quickly & easily detect the difference between the newly instantiated PBR and one that had been previously submitted?? I could check for previous transitions in the ChangeActions table, but that doesn't seem real speedy.

    Fallback is to add a flag to the function's params that indicates "new item" / "one that's been around the block".


    How/Why would an existing Project Based Record be submitted? Does the nature of the submit transition indicate that it would HAVE to be a new item?
    The reply is currently minimized Show
Your Reply

Recent Tweets