Solved

How to tell order line is created by "create transfer order"(SO509000) screen in coding?

  • 7 February 2021
  • 4 replies
  • 109 views

Userlevel 6
Badge +5

Hello, 

    We have an existed code customization that to set order line warehouse field to user’s default warehouse setting (which is a customization field)

      The main codes are like below

                Users currentUser = PXSelect<Users,
Where<Users.username, Equal<Current<AccessInfo.userName>>>,
OrderBy<Asc<Users.username>>>.Select(Base);
UsersExt userExt = PXCache<Users>.GetExtension<UsersExt>(currentUser);
cache.SetValueExt<SOLine.siteID>(row, userExt.UsrDefaultW);

 

       It is working fine, however we don’t like it to work when creating transfer orders by screen “SO509000”.

     we’d like to leave the line warehouse to Acumatica’s original logic when processing transfer order creation on screen "SO509000" 

 

    So, how can I tell the line is adding by request from “SO509000”?

icon

Best answer by Naveen Boga 7 February 2021, 18:00

View original

4 replies

Userlevel 7
Badge +17

Hi @ray20

 

You can add ScreenID condition before assigning the warehouse to SOLine siteID. Please find the sample code below.

 

// Base.Document.Current.LastModifiedByScreenID != "SO509000")

if(GraphName.ViewName.Current.LastModifiedByScreenID != “SO509000”)

{

// This Logic will NOT excute when the request coming from  Create Transfer Orders screen //SO509000

Users currentUser = PXSelect<Users, Where<Users.username, Equal<Current<AccessInfo.userName>>>, OrderBy<Asc<Users.username>>>.Select(Base); UsersExt userExt = PXCache<Users>.GetExtension<UsersExt>(currentUser); cache.SetValueExt<SOLine.siteID>(row, userExt.UsrDefaultW);

}

OR 

if(GraphName.ViewName.Current.CreatedByScreenID != “SO509000”)

{

// This Logic will NOT excute when the request coming from  Create Transfer Orders screen //SO509000

Users currentUser = PXSelect<Users, Where<Users.username, Equal<Current<AccessInfo.userName>>>, OrderBy<Asc<Users.username>>>.Select(Base); UsersExt userExt = PXCache<Users>.GetExtension<UsersExt>(currentUser); cache.SetValueExt<SOLine.siteID>(row, userExt.UsrDefaultW);

}

 

 

Hope this helps!!

Userlevel 6
Badge +5

@Naveen B  Thank you , my friend, I will try later.

Userlevel 6
Badge +5

@Naveen B 
Hello, forgive my poor coding knowledge,

According to my testing,

GraphName.ViewName.Current.CreatedByScreenID != “SO509000”
can not be compiled,
It might be I have to replace “GraphName” and “ViewName” with the real name.
But I don’t know which is what.

However,
Base.Document.Current.CreatedByScreenID != "SO509000"

This is working.

I can simply put the “Base.Document.Current.CreatedByScreenID” as the  if condition

Thank you.

Userlevel 7
Badge +17

Great...Thanks for the update

Reply


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2024  Acumatica, Inc. All rights reserved