cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
NurNina
Post Patron
Post Patron

Flow of creating sales order

Hi, I have a question. For sales order, I have two separate entities in creating order which are Sales Header and Sales Line.The SalesId is an autonumber field, will be created when a sales header is created.

Then, when I try to patch for Sales Line,it will lookup to the SalesId of Sales Header. 

 

Inside the canvas apps, there are two separate page in creating Sales Header and Sales Line. After creating Sales Header, I pass the variable of SalesId (SalesOrderID) when it navigates to Sales Line page:

 

sh.JPG

 

and here is the Sales Line page using the SalesOrderID created which is the SalesId1:

 

sl.JPG

 

Now I want to change the flow of creating sales order. I want to create both sales header and line in a single page, using a single button. How do I pass the SalesId value if I want to do it in that manner? 

 

1 ACCEPTED SOLUTION

Accepted Solutions
v-yutliu-msft
Community Support
Community Support

Hi @NurNina ,

Do you want to create  items in both sales header entity and sales order entity by using one button?

Then you do not need to use navigate function to pass salesid, you could directly use last(sales header) to get salesid to pacth sales order.

Formula should be like this:

Patch('Sales Order Headers',Defaults('Sales Order Headers'),{...});
Patch('Sales Order Lines',Defaults('Sales Order Lines'),
                           {....,SalesId1:Last('Sales Order Headers')}
     )
  

However, if updating in sales header entity costs some time, this formula may to some ambiguity.

So I suggest you add a timer to delay the patching action of 'Sales Order Lines' to make sure that Last('Sales Order Headers') is the last record that you just created.

You could set like this:
button for patching sales header entity:

Patch('Sales Order Headers',Defaults('Sales Order Headers'),{...});
Set(var,true)

 Timer's AutoStart:

var

Timer's Duration:

3000

//3s

Timer's OnTimerEnd:

Patch('Sales Order Lines',Defaults('Sales Order Lines'),
                           {....,SalesId1:Last('Sales Order Headers')}
     );
Set(var,false)

set the Timer's visible: false

 

Then every time you patch sales header entity, you will trigger the timer, after 3s, you will patch sales order enity.

 

Best regards,

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

1 REPLY 1
v-yutliu-msft
Community Support
Community Support

Hi @NurNina ,

Do you want to create  items in both sales header entity and sales order entity by using one button?

Then you do not need to use navigate function to pass salesid, you could directly use last(sales header) to get salesid to pacth sales order.

Formula should be like this:

Patch('Sales Order Headers',Defaults('Sales Order Headers'),{...});
Patch('Sales Order Lines',Defaults('Sales Order Lines'),
                           {....,SalesId1:Last('Sales Order Headers')}
     )
  

However, if updating in sales header entity costs some time, this formula may to some ambiguity.

So I suggest you add a timer to delay the patching action of 'Sales Order Lines' to make sure that Last('Sales Order Headers') is the last record that you just created.

You could set like this:
button for patching sales header entity:

Patch('Sales Order Headers',Defaults('Sales Order Headers'),{...});
Set(var,true)

 Timer's AutoStart:

var

Timer's Duration:

3000

//3s

Timer's OnTimerEnd:

Patch('Sales Order Lines',Defaults('Sales Order Lines'),
                           {....,SalesId1:Last('Sales Order Headers')}
     );
Set(var,false)

set the Timer's visible: false

 

Then every time you patch sales header entity, you will trigger the timer, after 3s, you will patch sales order enity.

 

Best regards,

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Top Solution Authors
Top Kudoed Authors
Users online (3,660)