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 / pcf assign output para...
Power Apps
Answered

pcf assign output params for canvas app operations

(0) ShareShare
ReportReport
Posted on by 4,702 Moderator

I am building a dataset type pcf specifically to embed in a powerapp. This control needs to perform limited API operations ("PUT") but since we don't have a webapi in pcf for canvas, that makes this part a bit tricky.

 

I want to be lazy about my coding and pass the operations back up to the containing powerapp so I can handle them there--where I don't need to handle my own authentication.

 

Is there a way to assign value to params of type "output" such that they can be picked up by a canvas app for OnChange events, or is my only real option here to import adal and use app authentication from inside pcf?

I have the same question (0)
  • Verified answer
    cchannon Profile Picture
    4,702 Moderator on at

    OK, I think I have it myself, at least partially...

     

    part 1: define the output param in ControlManifest.Input.xml:
    <property name="output" display-name-key="outputVal" description-key="Output from the conrol" of-type="SingleLine.Text" usage="output"/>

     

    part 2: define the datatype of the output in manifesttypes.d.ts:
    export interface IOutputs { output?: string; }

     

    part 3: attach your own notifyoutputchanged event to the init param:
    public init(context: ComponentFramework.Context<IInputs>, notifyOutputChanged: () => void, state: ComponentFramework.Dictionary, container:HTMLDivElement)
    {
    this._notifyOutputChanged = notifyOutputChanged;
    }

     

    part 4: designate a return val for the type defined in manifesttypes:
    public getOutputs(): IOutputs { return {output : "test"}; }

     

    part 5: call your notifyoutputchanged event wherever in code you want the change recognized:
    this._notifyOutputChanged();

     

    part 6: in PowerApps, add your pcf control, then add a label valued as <controlname>.output

     

    ... All that still missed the onchange part, but I am sure I will figure that out eventually.

  • alrezac Profile Picture
    Microsoft Employee on at

    Hi,

     

    Thanks for your follow up. I am glad you were able to get this issue figured out. Thanks for the information, hopefully it can help future communities members with their issues in the future. 

     

    Regards,

     

    Alex

     

    -------

     

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

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hi, @cchannon 

    I have been looking for something like this. Thanks for the share. 
    Do you mind sharing your code (as a zip file, maybe) so that I may compare it with mine to see where I am going wrong. 

    Thanks.

  • cchannon Profile Picture
    4,702 Moderator on at

    Wow. This is an old one. I don't still have the code for this, but the process is pretty simple: 

     

    • You update your manifest to declare the Output parameter
    • You rebuild your node project
    • You call notifyOutputChanged whenever you have a change to your value
    • You provide the updated value in getOutputs
    • You handle the outputs in your canvas app as <controlname>.output

    If you're hitting issues in there, is there a specific error message you're seeing?

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Let me try and provide some context.
    I have a separate javascript code that reads data from a serial port. I managed to convert the code to typescript. I am trying to include that very code (either one of two) into the index.ts file.
    I hope my explanation wasn't ambiguous. 

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Would it help if I attached the serial port code here? 

  • cchannon Profile Picture
    4,702 Moderator on at

    I've never tried to read from a serial port with a pcf, not even sure it is possible. In any event it is a totally separate topic from this one. I suggest you spin up a new thread to see if anyone else has tried it.

     

    But for the record, I'd first make sure you've enabled all uses-feature elements for Device:

    cchannon_0-1630590890862.png

    If all of them are enabled and you still can't read from the serial port, it might just not be a supported capability.

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!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 541

#2
WarrenBelz Profile Picture

WarrenBelz 434 Most Valuable Professional

#3
Valantis Profile Picture

Valantis 289

Last 30 days Overall leaderboard