Patch to SQL with Lookup Record
I am wanting to patch to an SQL table using a lookup as the record. Here is a summary of the setup:
1) I have a primary SQL table called "Planning". This table contains basically a project number and primary key that is related to every screen in my PowerApp.
2) A user searches and selects the Project No from a gallery which sources the "Planning" SQL table.
3) Upon selected of the Project No., the user would navigate to a general screen for "Contracts" data, which is the "ContractsGeneral" SQL table.
4) On the "General" screen, the user can add a new record and is blank if there is no record for the Primary Key. Or if there is a record for the Project No's Primary Key, then just modify the data and hit save.
5) For the Patch function, using LOOKUP function for the record is not working. "Invalid argument type (Number). Expecting a Record value instead." Both columns in SQL are INT type. Here is my patch function and screen shots below:
If(gblNewGeneralContract,
Patch(
ContractsGeneral,
Defaults(ContractsGeneral),
{
Projects_fk:gal_Contracts.Selected.pk_Projects,
Bids_Received:Date_BidsReceived.SelectedDate,
Modified:Now(),
Modified_By:User().FullName
}
);,
Patch(
ContractsGeneral,
LookUp(ContractsGeneral,gal_Contracts.Selected.pk_Projects=Projects_fk,pk_ContractsGeneral),
{
Projects_fk:gal_Contracts.Selected.pk_Projects,
Bids_Received:Date_BidsReceived.SelectedDate,
Modified:Now(),
Modified_By:User().FullName
}
);
);
Set(gblNewGeneralContract,false)
6) I was expecting this to work easy. I have several solutions that I could try but wanted to know if anyone has experience this. I could just create a gallery on this screen to select the record but didn't want to clutter up the screen.
2
4 comments
James Hammons
2
Patch to SQL with Lookup Record
Learn Power Apps
skool.com/learn-power-apps
A community of people who are enthusiastic about and trying to learn about Microsoft's Power Apps!
Leaderboard (30-day)
Powered by