SY_WebhookSubscription.ItemNo

Discussions relating to the REST API of Jiwa 7.

SY_WebhookSubscription.ItemNo

Postby SBarnes » Mon Aug 03, 2020 2:38 pm

How is the value of SY_WebhookSubscription.ItemNo determined, because it looks like every row is getting the value of 1?
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1618
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: SY_WebhookSubscription.ItemNo

Postby SBarnes » Mon Aug 03, 2020 7:09 pm

How does SY_WebhookSubscription.ItemNo also work?
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1618
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: SY_WebhookSubscription.ItemNo

Postby Mike.Sheen » Tue Aug 04, 2020 11:59 am

The ItemNo of the SY_WebHookSubscription is set for you automatically when a POST is made to /Webhooks/Subscribers/{SubscriberID}/Subscriptions/

It uses the maximum item No of the existing SY_WebhookSubscription.ItemNo for the same Subscriber as you are creating the subscription for.

Code: Select all
Db.ExecuteSql(@"INSERT INTO SY_WebhookSubscription (RecID, SY_WebhookSubscriber_RecID, EventName, URL, ItemNo, LastSavedDateTime)
    VALUES (@RecID, @SY_WebhookSubscriber_RecID, @EventName, @URL, (SELECT COALESCE(MAX(ItemNo), 0) + 1 FROM SY_WebhookSubscription WHERE SY_WebhookSubscription.SY_WebhookSubscriber_RecID = @ItemNo_SY_WebhookSubscriber_RecID), SYSUTCDATETIME())",


So, if you were to look at a list of all the subscriptions for a particular subscriber id, you should have sequential item no's for the SY_WebhookSubscription records.
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2444
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 756

Re: SY_WebhookSubscription.ItemNo

Postby SBarnes » Tue Aug 04, 2020 12:45 pm

I hate to tell you but it doesn't do that see below, I had found the code you mentioned in the Rest api plugin and thought I was misreading the code somehow, this is by using swagger

webhooks.jpg
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1618
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: SY_WebhookSubscription.ItemNo

Postby Scott.Pearce » Tue Aug 04, 2020 1:02 pm

Please log a bug.

Code: Select all
            Db.ExecuteSql(@"INSERT INTO SY_WebhookSubscription (RecID, SY_WebhookSubscriber_RecID, EventName, URL, ItemNo, LastSavedDateTime)
                                 VALUES (@RecID, @SY_WebhookSubscriber_RecID, @EventName, @URL, (SELECT COALESCE(MAX(ItemNo), 0) + 1 FROM SY_WebhookSubscription WHERE SY_WebhookSubscription.SY_WebhookSubscriber_RecID = @ItemNo_SY_WebhookSubscriber_RecID), SYSUTCDATETIME())",
                              new
                              {
                                  RecID = newSubscription.RecID,
                                  SY_WebhookSubscriber_RecID = newSubscription.SY_WebhookSubscriber_RecID,
                                  EventName = newSubscription.EventName,
                                  URL = newSubscription.URL,
                                  ItemNo_SY_WebhookSubscriber_RecID = newSubscription.RecID
                              });


I can see that ItemNo_SY_WebhookSubscriber_RecID is being set to newSubscription.RecID instead of newSubscription.SY_WebhookSubscriber_RecID.
Scott Pearce
Senior Analyst/Programmer
Jiwa Financials
User avatar
Scott.Pearce
Senpai
Senpai
 
Posts: 742
Joined: Tue Feb 12, 2008 11:27 am
Location: New South Wales, Australia
Topics Solved: 221

Re: SY_WebhookSubscription.ItemNo

Postby SBarnes » Tue Aug 04, 2020 1:24 pm

Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1618
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175


Return to REST API

Who is online

Users browsing this forum: No registered users and 2 guests

cron