Skip to main content
Solved

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

  • February 7, 2021
  • 4 replies
  • 118 views

Forum|alt.badge.img+5
  • Captain II
  • 398 replies

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”?

Best answer by Naveen Boga

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!!

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

4 replies

Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • 3410 replies
  • Answer
  • February 7, 2021

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!!


Forum|alt.badge.img+5
  • Author
  • Captain II
  • 398 replies
  • February 8, 2021

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


Forum|alt.badge.img+5
  • Author
  • Captain II
  • 398 replies
  • February 8, 2021

@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.


Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • 3410 replies
  • February 8, 2021

Great...Thanks for the update


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