cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Regular Visitor

Passing a value between forms

I am truly struggling with the concept of opening a new record and filling in one or more fields before the user fills in any info.

 

I have a form (JobDetaislForm) bound to a Sharepoint List; tblJobs

 

In this form I have a Gallery (NoteGallery) control bound to tblJobNotes, filtered by the selected JobID

 

Filter(tblJobNotes, JobID = SelectedJob.Text)

I have a button which moves to a new form to edit each note:

 

Navigate(NoteForm,ScreenTransition.UnCover)

The Form, NoteForm is bound to tblJobNotes and contains the usual DataCards with the right fields to complete. This works just fine.

 

Back to JobDetailsForm; I have a button to ADD a new note -

 

NewForm(EditNotes);Navigate(EditNotes, ScreenTransition.None)

This works - up to a point; it does not apply the Note to the selected job by completing the field "JobID" (in tblJobNotes) with the Selected Job (from tblJobs - stored in JobDetailsForm in the control "SelectedJob".

 

I'm sure this is bread and butter, 101 stuff; but my Google-Fu is failing me. Can someone help me?

 

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Helper V
Helper V

Re: Passing a value between forms

Hi ChrisMa, Please don't be frustrated. Like any new tool, it will take some blood, sweat, and tears to make this work, 

so take a deep breath and do this in order:

 

1) In the default value of the data card for the JobId on the notes entry form, place the instruction "Gallery1.Selected.ID" you will need to rename the gallery if it is not Gallery1 in this case. This tells the form to refer to the "Job gallery ID" as the default value for the text box on the data card fior the JobID on your notes form. You will probably have to unlock it and use the advanced editor feature of the data card to find the default attribute. 

 

2) If this is a no go, and you want to try the patch method to create the record before the notes edit form pops,  I want you to do a little bit of homework and then I will give you the command right below this for a patch. Read the example of patch to create a record for the notes list. It is on this link, look for "strawberry" and read the formula, description and result columns for the most basic example listed here: https://powerapps.microsoft.com/en-us/tutorials/function-patch/    

 

3) This is a plot spoiler, but if you put this command on your first form for job data entry, on a button called "make notes" it should work just fine. You will have to supply the unique key field name for the notes list, but this should do it for JobID number 1 in your list. It's hard coded to insert a note for JobID 1 in other words, then you play with it to make it work in the next step. 

 

Patch( tblJobNotes, Defaults( TblJobNotes ), { JobId: 1 },{TypeOverYourUniqueKeyForTheNotesListHere: "My New Job Note"} )

 

4) If you do it this way, then all you need to do is supply the JobID field, which your notes seem to indicate is

JobDetailsForm.SelectedJob.Text, so the syntax would be:

 

Patch( tblJobNotes, Defaults( TblJobNotes ), { JobId: JobDetailsForm.SelectedJob.Text },{TypeOverYourUniqueKeyForTheNotesListHere: "My New Job Note"} )

 

This gets us to the core of the issue, your JobId seems to be hidden somehow. Here is what I always do at this frustration point: If you put a text box on the Job Entry form to display what you suspect is the jobID, you can see what it is before the code drives you nuts. It will be an integer like 7 if you are just starting to put data into your list objects. Try displaying (on your edit job form) the gallery1.Selected.ID field, and see if that is not indeed your job id for the job record. I think it will make sense then. 

 

The data type jibberish on my other patch command, was because my ID in the example, was a complex lookup field in Sharepooint, so I needed to pass the schema name of the table that the ID came from. It's ugly, and even I don't like that Odata typing stuff! Add to that the data source contains some letters that were masked by a bleep, and it looks very strange, even to me! Sorry bout that. 

 

Try to have fun with it, and best wishes to you!

SmartMeter.

 

 

 

 

View solution in original post

5 REPLIES 5
Highlighted
Helper V
Helper V

Re: Passing a value between forms

So your job to notes is a 1:M relationship, try one of these two tricks. Either put a button directly on your job gallery so it has has awareness of the selected parent record id (gallery1.selected.jobid) and jump to the notes form directly from the selected line button, Or, you can patch (create) a new generic record for each note by firing off a command from a button (again on your job level gallery.) I do this, and the patch method works fine.The point is, you link the child to the parent when you spawn the child,and set a default generic title, so the person can rename the notes as needs be. Hope one of these helps 😉

(Sample patch command)

 

Patch(Fini**bleep**,Defaults(Fini**bleep**),{Issue:{'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",Id:BrowseGallery1.Selected.ID,Value:BrowseGallery1.Selected.Title}},{Title:"Please describe and assign this new task..."},{TextIssue:BrowseGallery1.Selected.Title})

Highlighted
New Member

Re: Passing a value between forms

Thanks for replying. I'm sorry - I just don't get it - I can see the patch command is the clue, but the example you have given me makes little sense in the format you've provided.

 

The gallery part is fine; that works - I can navigate and edit exising records fine. It's adding a new related record thats the issue.

 

I have a button which creates the record:

 

NewForm(EditNotes);Navigate(EditNotes, ScreenTransition.None)

 

I need to pass the value JobID from this form to EditNotes and Patch the new record with the current JobID. I can see when I navigate to the new screen that the record is not actually created until I SubmitForm, but I can't see how I create the new record and patch the right value.

 

As it stands, if I fill in the data in the form, it DOES create a new record (when submitted) - I simply need it to have "JobID" pre-populated.

 

Capture.JPGCapture2.JPG

 

It seems such a basic thing, very frustrating!

 

Thanks

 

Chris

 

:Urgh - also just realised I used a new account to post. Noob.

Highlighted
Helper V
Helper V

Re: Passing a value between forms

Hi ChrisMa, Please don't be frustrated. Like any new tool, it will take some blood, sweat, and tears to make this work, 

so take a deep breath and do this in order:

 

1) In the default value of the data card for the JobId on the notes entry form, place the instruction "Gallery1.Selected.ID" you will need to rename the gallery if it is not Gallery1 in this case. This tells the form to refer to the "Job gallery ID" as the default value for the text box on the data card fior the JobID on your notes form. You will probably have to unlock it and use the advanced editor feature of the data card to find the default attribute. 

 

2) If this is a no go, and you want to try the patch method to create the record before the notes edit form pops,  I want you to do a little bit of homework and then I will give you the command right below this for a patch. Read the example of patch to create a record for the notes list. It is on this link, look for "strawberry" and read the formula, description and result columns for the most basic example listed here: https://powerapps.microsoft.com/en-us/tutorials/function-patch/    

 

3) This is a plot spoiler, but if you put this command on your first form for job data entry, on a button called "make notes" it should work just fine. You will have to supply the unique key field name for the notes list, but this should do it for JobID number 1 in your list. It's hard coded to insert a note for JobID 1 in other words, then you play with it to make it work in the next step. 

 

Patch( tblJobNotes, Defaults( TblJobNotes ), { JobId: 1 },{TypeOverYourUniqueKeyForTheNotesListHere: "My New Job Note"} )

 

4) If you do it this way, then all you need to do is supply the JobID field, which your notes seem to indicate is

JobDetailsForm.SelectedJob.Text, so the syntax would be:

 

Patch( tblJobNotes, Defaults( TblJobNotes ), { JobId: JobDetailsForm.SelectedJob.Text },{TypeOverYourUniqueKeyForTheNotesListHere: "My New Job Note"} )

 

This gets us to the core of the issue, your JobId seems to be hidden somehow. Here is what I always do at this frustration point: If you put a text box on the Job Entry form to display what you suspect is the jobID, you can see what it is before the code drives you nuts. It will be an integer like 7 if you are just starting to put data into your list objects. Try displaying (on your edit job form) the gallery1.Selected.ID field, and see if that is not indeed your job id for the job record. I think it will make sense then. 

 

The data type jibberish on my other patch command, was because my ID in the example, was a complex lookup field in Sharepooint, so I needed to pass the schema name of the table that the ID came from. It's ugly, and even I don't like that Odata typing stuff! Add to that the data source contains some letters that were masked by a bleep, and it looks very strange, even to me! Sorry bout that. 

 

Try to have fun with it, and best wishes to you!

SmartMeter.

 

 

 

 

View solution in original post

Highlighted
New Member

Re: Passing a value between forms

Thank you. This is exceptionally helpful - and the first point is the most blinding (maybe frustratingly) simple solution.

 

I did have a look at the Patch command - and I can see how it works now. Your example is much clearer (or relevant to me) and I have been able to create a button that does create a new record (as well as update the correct JobID). I can tell it works, because a blank "Note" appears almost immediately in the gallery for the Job Detail.

 

While it wouldn't be my go to method; I am trying to get my head around how I navigate to this new record (or note) I have created. Creating a unique identifier I suppose I could do a number of ways; but is there a right way to do this? (Patch a new record, then get the ID of the new record and display it).

 

At any rate, my initial question is most certainly answered. Kudos to you.Smiley Happy

Highlighted
Helper V
Helper V

Re: Passing a value between forms

Glad it helped! 

To your question, try this, in your child Note SP list linked by JobID, make the SharePoint Title field (a single line of text) instructing the user to overlay a generic phrase with human wisdom. This can be done by patching in a simple, "vanilla" JobNote title as a generic temporary place holder. Think of it as a note template and use something like "Please Describe." or "Your Note Title goes here." Then, pop the edit form on them right after your patch command. As for the right way to do this, I am sure you will find the way if you seek 😉

Helpful resources

Announcements
secondImage

Demo-Extravaganza 2020

Check out these cool Power Apps & vote on your favorite!

secondImage

Community Highlights

Check out whats happening in Power Apps

secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (11,214)