Skip to main content
Solved

Implementing webhook in 24R2


angelesosorno86
Freshman II
Forum|alt.badge.img

Hi everyone. I need to create a webhook, but I'm having trouble accessing AccesInfo.BranchID. I tried using PXContext.GetBranchID(), but it doesn't work. Does anyone know the best way to implement this?

Best answer by harutyungevorgyan

Hello  ​@angelesosorno86  ,

 

You are not the only one, and it seems something changed or doesn't work as expected with webhooks in 24R2, especially with the AP module. We are having trouble now as well with this, and we opened a case because simple solutions with PXLoginScope don't work. For now, you can try PXLogin.SetBranchID(setTheHardcodeBranchID) to set branchID in your loginscope but I believe it will just change the problem and give you another error.

 

I will let you know if we find a solution.

View original
Did this topic help you find an answer to your question?

6 replies

darylbowman
Captain II
Forum|alt.badge.img+13

What are you trying to to do with it? Did you create a graph instance in your code? You can get AccessInfo from *graph instance*.Accessinfo.


angelesosorno86
Freshman II
Forum|alt.badge.img

Hi @darylbowman. I'm trying to insert an APInvoice document using a webhook, but this document should use the BranchID value. However, in this context, I didn't have a BranchID, and I tried using AccessInfo via a graph instance, but it didn't work. This value was null, and if I didn't have it, the document wouldn't be created.


darylbowman
Captain II
Forum|alt.badge.img+13

I can’t say I’ve ever used AccessInfo in a webhook, but I would expect any graph instance to have valid AccessInfo. Could you post that section of code?


angelesosorno86
Freshman II
Forum|alt.badge.img

Yes, I did.

Basically I created a graph instance ( APInvoiceEntry invoiceGraph = PXGraph.CreateInstance<APInvoiceEntry>();)  and I want to access AccesInfo.BranchID but this value was null and ScreenID was also null. 

using (var scope = GetAdminScope()) // This is how it runs in the webhook, in the admin scope, so thought I could give it a test.
 {

     APInvoiceEntry invoiceGraph = PXGraph.CreateInstance<APInvoiceEntry>();
     invoiceGraph.Accessinfo.ScreenID = "SM304000";

     var invoice = new APInvoice();

     invoiceGraph.Document.Cache.SetValueExt<APInvoice.docType>(invoice, APDocType.Invoice);

     invoice = invoiceGraph.Document.Insert(invoice);

     string value = archivo.date.ToString();
     DateTime datetime = DateTime.Parse(value);
     invoice.DocDate = datetime.Date;
     invoice.BranchID = invoiceGraph.Accessinfo.BranchID;
 }

 


harutyungevorgyan
Jr Varsity I
Forum|alt.badge.img+1

Hello  ​@angelesosorno86  ,

 

You are not the only one, and it seems something changed or doesn't work as expected with webhooks in 24R2, especially with the AP module. We are having trouble now as well with this, and we opened a case because simple solutions with PXLoginScope don't work. For now, you can try PXLogin.SetBranchID(setTheHardcodeBranchID) to set branchID in your loginscope but I believe it will just change the problem and give you another error.

 

I will let you know if we find a solution.


angelesosorno86
Freshman II
Forum|alt.badge.img

Hi @harutyungevorgyan. Thank you. I hope this issue is resolved soon. I’ll try to fix it and you can use this instruction PXContext.SetBranchID(setTheHardcodeBranchID);


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings