James Butler
New Member.
10772 views

Access to system table in notification context?


Can system tables be accessed in a notification script context? For example: Set recGroups = Ext.CreateAppRecord(Ext.TableId("TS_GROUPS"))
0 Likes
30 Replies
mobermaier Absent Member.
Absent Member.

Re: Access to system table in notification context?


Yes,
just keep in mind that the notification context only gives you the table/record for which the notification was triggered, not the record itself
Shell.TableID 'table ID
Shell.ItemID 'record ID
Shell.User 'referring to the subscriber being processed
0 Likes
jwalnum Absent Member.
Absent Member.

Re: Access to system table in notification context?


Sorry to jump in here, but I have a closely related question. Is it possible to update the current record using an AppRecord within the notification script context?
I'm trying to set a text field (or any field for that matter ) via a Notification Script call.
I'm doing a:
Set sysRec = Ext.CreateAppRecord(sysTable)
whereClause = "TS_ID = " & thisID
If sysRec.ReadWithWhere(whereClause) Then
ok = sysRec.SetFieldValue("LAST_NOTE","test")
End If
but it never sets the value. I have verified that the ok is true on the SetFieldValue
The "thisID' is the current record in the Script...
Thx
0 Likes
James Butler
New Member.

Re: Access to system table in notification context?


I have access to the record that triggered the notification but I am trying to access system tables to retrieve information that I need to set in a primary item that is created in this script but the above syntax I gave is not working. Any ideas why I would not be able to access a system table such as ts_groups from this context?
0 Likes
James Butler
New Member.

Re: Access to system table in notification context?


You have to call UpdateWithLock(true) on sysRec to save it to the table.

In a notification context there is no shell.item and no transition so the system does not automatically update any records.

Set sysRec = Ext.CreateAppRecord(sysTable)

whereClause = "TS_ID = " & thisID

If sysRec.ReadWithWhere(whereClause) Then

sysRec.SetFieldValue("LAST_NOTE","test")

ok = sysRec.UpdateWithLock(true)

End If
0 Likes
mobermaier Absent Member.
Absent Member.

Re: Access to system table in notification context?


You don't have access (may be a permission issue) or you do not get any data/rows?
I have a script running in the notification context accessing an auxiliary table (read) and a system table (TS_NOTIFICATIONMESSAGES / write) working just fine in TeamTrack 6.6.1.
0 Likes
jeff_malin Absent Member.
Absent Member.

Re: Access to system table in notification context?


Just a suggestion, if you're accessing a record which could potentially be edited by a user, you don't want to do UpdateWithLock(true) because that could cause a user in the Web Interface to loose changes if they were editing at the same time. Rather, you'll want to do "if sysRec.Lock() then [do your thing, sysRec.update(), sysRec.unlock()] else [shell.redomessage = "item locked"]". The "lock()" method will return true if it's able to lock it, and false if the item is already locked. In the latter case, setting shell.redomessage will fail the Notification context script, then you can set the Notification to re-try on script failure a specified number of times. That way, the script waits until the user finishes their work and releases the lock, and you don't end up stealing locks and clobbering anyone's data.
0 Likes
James Butler
New Member.

Re: Access to system table in notification context?


Well, I found out why that was not working for me. The value I was using in the where clause was not getting set before that call to the system table. I thought that part was getting values but there was a record in that aux table that was all nulls. Got it working now.
0 Likes
jwalnum Absent Member.
Absent Member.

Re: Access to system table in notification context?


Thanks James and Jeff for my sub thread. It works with the Update!

ok = sysRec.UpdateWithLock(true)
0 Likes
James Butler
New Member.

Re: Access to system table in notification context?


Hey Jeff, how you doing? Thanks for that bit of info.

BTW, can you send me some vbscript that accesses SBM by using a cookie instead of basic auth? I sure could use it right now.
0 Likes
jeff_malin Absent Member.
Absent Member.

Re: Access to system table in notification context?


Hi James - so you have a VBS today that's setting the authentication header to Basic + the base64 encoded username/password? There's not much difference between doing it like that, and doing it as a cookie - I can't seem to find any of my old code but from what I recall you just set a header of "set-cookie" with the value of "authentication:(base64 encoded username/password").
0 Likes
James Butler
New Member.

Re: Access to system table in notification context?


Thanks Jeff, I'll try that. I am using your code from the "Create a recurring task" post. It logs in but does not execute the teamscript that I'm telling it to execute. So I will try the set-cookie in the header and see if that works.
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.