cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
AVTS
Post Partisan
Post Partisan

Exception Handler in Collection to Dataverse Table

Experts,

 

I have got Collection named as DailyinventoryL  and Dataverse table named as  Dailyinventory . Following button click is to send the data from collection to table.

 

Set(Varlastno1 ,
First(
FirstN(Sort(DailyinventoryL,sno, Descending),
1
)
).sno);


ForAll(
DailyinventoryL,
Patch(
Dailyinventory,
Defaults(Dailyinventory),
{
crf99_materialno: Materialno,
crf99_materialdesc: Materialdesc,
crf99_plant: plant,
crf99_qty: Qty,
crf99_bbd: BBD
}
)
);

Set(
varNotifytest9,
"Transmit Completed"
);
Set(Varlastno1 ,
First(
FirstN(Sort(DailyinventoryL,sno, Descending),
1
)
).sno);

------

 

Issue here is that duplicated data is transmitted to table whenever clicking the button 

 

Requirement here is that button should trigger error message if that is duplicated is passed.

 

Tried with workaround like bringing the last row of the collection records as variables. 

Var created. 

 

Set(Varlastno1 ,
First(
FirstN(Sort(DailyinventoryL,sno, Descending),
1
)
).sno);

 

Var is passed to one label. So whenever button is clicked then last row number will appear in the label12.

 

Now how to send the collections to table which is after the lastrow number which is appearing in label12. Not sure this is correct way. 

1 REPLY 1
iAm_ManCat
Super User
Super User

Hi, you will want to look at the datasource for the last submitted item rather than the collection:

Refresh(Dailyinventory);
Set(Varlastno1,
      First(
         Sort( Dailyinventory, sno, Descending)
      ).sno
);

 

This way it will never use a Varlastno1 that is already in use, as it checks the datasource for the most recent number

@iAm_ManCat


Please 'Mark as Solution' if someone's post answered your question and always 'Thumbs Up' the posts you like or that helped you!


Thanks!
You and everyone else in the community make it the awesome and welcoming place it is, keep your questions coming and make sure to 'like' anything that makes you 'Appy
Sancho Harker, MVP


Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

365 EduCon 768x460.png

Microsoft 365 EduCon

Join us for two optional days of workshops and a 3-day conference, you can choose from over 130 sessions in multiple tracks and 25 workshops.

Users online (2,454)