web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Creating a record and ...
Power Apps
Answered

Creating a record and passing the record to another record with Canvas App, Dynamics 365 CDS

(0) ShareShare
ReportReport
Posted on by 11

Hello everyone,

 

I am currently working on my first canvas app so please be patient.

I am trying to accomplish the following:

 

I have a create of a record (in CRM via Canvas app). After this record is created, I would like to pass that record to a different creation, with a lookup on the record I created previously.

 

so I have this create:

Patch( 'Application Schedules' ; Defaults('Application Schedules') ; {Application : "Set Recipients" ; 'Status Reason' : 'Status Reason (Application Schedules)'.'Under Construction' ; Name : "Set Recipients"})

 

which works and creates my "Application Schedule".

 

Now, I need to create a "Application Schedule Parameter" which "belongs" to my previously created Schedule.

Something like this:

Patch( 'Application Schedule Parameter' ; Defaults('Application Schedule Parameter') ; {'Application Schedule Parameter'.'Application Schedule' : Previously Created Application Schedule ; })

 

but I have no idea how to pass the first record to the second one.

 

Both of these actions, need to happen in succession, not absolutely required in the same event.

Right now I am trying to accomplish this onVisible of a screen, one after the other with chaining (;;)

Please keep in mind, I have ; as a separator because I am in Austria and I cannot use , 

 

Any and all help would be greatly appreciated.

Thank you.

Sergiu

 

 

Categories:
I have the same question (0)
  • Drrickryp Profile Picture
    Super User 2024 Season 1 on at

    Hi @Sergiu_S 

    I would suggest that you use 

     

    Set(lastsubmitID,First(Sort('Application Schedules',ID,Descending)).ID)

     

    To capture the ID of the Patched record as a global variable (lastsubmitID is an arbitrary name, it could be anything). 

     

    Patch( 'Application Schedules' ; Defaults('Application Schedules') ; {Application : "Set Recipients" ; 'Status Reason' : 'Status Reason (Application Schedules)'.'Under Construction' ; Name : "Set Recipients"});;Set(lastsubmitID;First(Sort('Application Schedules';ID;Descending)).ID)
    
     

     

     

    You can then use that to identify the record in a subsequent patch and to apply it to the foreign key.  You can also use it in a Lookup for the other fields in your parent table. 

     

    Lookup(ParentTable;ID=lastsubmitID;OtherFieldInParentTable)

     

     

     

  • Sergiu_S Profile Picture
    11 on at

    @Drrickryp  thank you very much for your reply. I thought I would have to use a variable to store it but was doing it completely wrong. Sadly this doesn't work either at the moment. I get the following error:

     

    incompatible type. we can't evaluate your formula because the context variable types are incompatible with the types of values in other places in your app

     

    From what I researched on the error, it appears when you assign 2 different value types to a variable but I can't see how that would be the case since this is the only place this variable is used (tried copy/paste-ing exactly as your post, giving it the name I used before, just calling it "test", same error every time)

     

    Any idea why this could be?

     

    Thank you.

    Sergiu

  • Verified answer
    Sergiu_S Profile Picture
    11 on at

    Ok, I figured it out.

    I figured that ID was generic so I tried it but it is not, after that I tried the actual field name where the GUID is stored, still didn't work...so I resorted to SortbyColumn, that let me choose the name of the actual field for the GUID (going back to Sort allowed it btw....super weird but whatever. It works)

    but now I am faced with a different issue, the actual Patch that I am trying to accomplish from my initial post.

     

    I now have this: 

    Patch( 'Application Schedule Parameter' ; Defaults('Application Schedule Parameter') ; {'Application Schedule': AppSchedule } ...etc })

    Which obviously does not work, since Application Schedule is a record and AppSchedule holds the GUID but 'Application Schedule'.ApplicationScheduleGUIDField  does not work, so I tried this:

    Patch( 'Application Schedule Parameter' ; Defaults('Application Schedule Parameter') ; {'Application Schedule': { cf_applicationscheduleid: AppSchedule } })

     

    which seems to be acceptable but also requires other fields concrete error I am getting is that it expects Owner for some reason

     

    also tried with 'Application Schedule'.Value : AppSchedule but nope...

     

    Any hints?

     

    Thank you.

    Sergiu

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 493 Most Valuable Professional

#2
11manish Profile Picture

11manish 479

#3
Haque Profile Picture

Haque 328

Last 30 days Overall leaderboard