cancel
Showing results for 
Search instead for 
Did you mean: 
Reply

power apps component framework , type script

Hi, I am new to power apps component framework and typescript. I am trying to create a button in type script and add the click listener to the button. I could manage to create a button by calling document.create Element("button");

 

1. Could you please help me about how should i add a click listener to the button. 

Also, i could see the button in the web page http://127.0.0.1:8181/

2. When i import that component in power apps, i could not see the button in power apps, I am not sure what i am doing wrong. 

I am sure that i am importing it correct, because i tried to create a sample components  from the Microsoft documentation, i could see the TS Linear Input Component in the web page, also in power apps.

Please could some one assist me

Thanks in Advance

9 ACCEPTED SOLUTIONS

Accepted Solutions
a33ik
Most Valuable Professional
Most Valuable Professional
HemantG
Power Apps
Power Apps

>> 1. Could you please help me about how should i add a click listener to the button

Check out the control set state sample button.addEventListener("click", event => this.onButtonClick(event, this._selectedColorElement)

 

>> 2. When i import that component in power apps, i could not see the button in power apps, I am not sure what i am doing wrong. 

Is the custom control rendered at all or you see the default PB control. Cross check that you have published the solution and the control version is bumped in the manifest so that latest control changes are reflected. Check the code in browser debugger  to see if there are any control rendering issues. 

 

Hemant 

View solution in original post

You need to run pac pcf push -pp vani -f from the same directory you would run npm run build in.

 

 

---
If this post has answered your question please consider it for "Accept as Solution" or if it has been helpful give it a "Thumbs Up".

View solution in original post

To create a profile the command line command is

 

pac auth create --url https://Url_including_.dynamics.com bit for instance https://testinstance.crm11.dynamics.com but it could be org123srs2.crm4.dynamics.com if you are using a powerapp.

 

that will popup the login screen and allow you login and create your credentials which will then be cached for further use until they change or expire.

---
If this post has answered your question please consider it for "Accept as Solution" or if it has been helpful give it a "Thumbs Up".

View solution in original post

Thanks for the reply

I create the authentication profile using the below

PS C:\Users\vani\Documents> pac auth create --url https://testinstance.crm11.dynamics.com
Authentication successfully created.
Validating connection...
Connected to...
Could not connect to the CDS Organization at https://testinstance.crm11.dynamics.com.

Error: Unable to Login to Dynamics CRM

==============================

I also tried as below

PS C:\Users\vani\Documents> pac auth create --url https://metamicro123.crm11.dynamics.com
Microsoft PowerApps CLI
Version: 1.1.6+g29558dc

Error: An error occurred while sending the request.
The remote server returned an error: (502) Bad Gateway.

 

Please could you advise! Thanks

View solution in original post

When you open / play the application you are trying to attach the PCF component to the url is the bit below in the browser.

Screenshot_43.png

 

 

In the screenshot above https://org875b999.crm4.dynamics.com is my sandbox instance for one of the things we are working on - as with https://testinstance.crm11.dynamics.com you won't be able to connect to it as that is another of my development instances.

 

For reference - the url of a Dynamics or model driven power app is in 2 bits.

 

your instance name . crm / azure region followed by dynamics.com 

 

you need to know your organization name I'm guessing its'  metamicro123 and the number for the crm region metamicro123 is in (as it is clearly not in region  11 which is the UK) so the url will be something like https://metamicro123.crm?.dynamics.com where the ? is the number for the azure region your instance is in. 

 

---
If this post has answered your question please consider it for "Accept as Solution" or if it has been helpful give it a "Thumbs Up".

View solution in original post

Thank you very much for the reply. you are correct about this, and i managed to get the URL and created the authentication profile.

Now i am trying to use the command pac pcf push --publisher-prefix dev and i am getting the following errors. I do see the zip file named powerAppsTools_dev in the path C:\Users\vani\Documents\RetrieveQuestionComponent\obj\PowerAppsTools_dev\bin\Debug.

But i dont see the powerAppsTools_dev in power apps.

 

Error: Import Solution Failed: CustomControl with name QuestionNamespace.RetrieveQuestionInputComponent failed to import with error: CustomControls with Name QuestionNamespace.RetrieveQuestionInputComponent Import Solution Failed with following error: The forceupdate flag for the control QuestionNamespace.RetrieveQuestionInputComponent is set to true but the control version in the solution is less than the control version in CDS. Please make sure the versions are atleast equal.

 

Please could you advise,

 i am new to the PCF and learning. 

View solution in original post

The quickest way to fix that is to:-

 

login to Dynamics and

 

remove the custom control from the page it is on (just open the field and delete it).

publish the page

delete the existing version of the control

 

then publish the control from the command line

 

and add it to the control it was attached to before.

 

I'm sure someone else will come along with the actual solution but I encountered the same issue when I moved from using the build and import approach to the push approach and I didn't have time to wait for an answer.

 

---
If this post has answered your question please consider it for "Accept as Solution" or if it has been helpful give it a "Thumbs Up".

View solution in original post

Hi @ben-thompson 

The issue is due to incrementing the control version and using push.  For now the workaround is to not increment the control version and push, or do as you suggested and remove and re-add the solution.  There has already been a fix checked in on the code side to fix the root cause of the issue, but it hasn't made it to all the way down to all regions yet.  It will hopefully be available in the NA region at the end of this week though.

View solution in original post

13 REPLIES 13
a33ik
Most Valuable Professional
Most Valuable Professional

HemantG
Power Apps
Power Apps

>> 1. Could you please help me about how should i add a click listener to the button

Check out the control set state sample button.addEventListener("click", event => this.onButtonClick(event, this._selectedColorElement)

 

>> 2. When i import that component in power apps, i could not see the button in power apps, I am not sure what i am doing wrong. 

Is the custom control rendered at all or you see the default PB control. Cross check that you have published the solution and the control version is bumped in the manifest so that latest control changes are reflected. Check the code in browser debugger  to see if there are any control rendering issues. 

 

Hemant 

Hi Hemant,

Thanks you for your reply. I could add the click listener to the button now. and it works fine. thanks for that.

 

but if i make some change in the typescript file(index.ts). i could see the change in the browser.

For example, i followed the code as you have mentioned in the GIT hub, to add a button with event listener. The first time, when i import the solution zip file from power apps, i could see the button and i can click on it which is fine

 

Now i make a small change, (eg: i display a text on the button). and run npm start. i can see the change in the web page, i want to see the text in the power apps also. so i follow the same steps again like creating solution folder, running the pac solution init --publisher-name developer --publisher-prefix dev, adding reference, msbuild /t:restore, msbuild. when i import the newly created solution zip file, i am not able to see the change in power apps.

 

Do i need to change the control version in the manifest file  every time i create a solution?

so the first time, i am seeing the control what i need to see in power apps, second time the changes are not shown

 

 

If you are building the solution file manually you need to increment the version number in the controlmanifest file before compiling the component and building the solution file.

 

Instead of continually doing the manual steps above (which used to be the only way) it's better to just publish the solution from the command line using the following command 

 

pac pcf push -pp (publishername) -f

 

see https://d365spartan.wordpress.com/2019/09/12/powerapps-component-framework-pcf-push/ for slightly more details.

---
If this post has answered your question please consider it for "Accept as Solution" or if it has been helpful give it a "Thumbs Up".

Hello,

when i run the pac pcf push -pp vani -f i get the error 

Error: PowerApps component framework project file with extension pcfproj was not found in the directory C:\Users\vani\Documents\loginComponent\solution.

 

But i have manged to get the changes visible in power apps by deleting the solution from the environment in power apps and import the solution zip file again. i think there should be some easier way to do this.

 

Also, could you guide me how to pass parameters from power apps to the typescript (index.ts)

for eg: i have created a input field and button in the typescript. if i type 5 in the input box and press the button, it will return the square of 5  = 25.

I import this component to power apps, and from power apps i have to pass the parameter as 2 and typescript should return 4. is this possible. could you guide me with this?

You need to run pac pcf push -pp vani -f from the same directory you would run npm run build in.

 

 

---
If this post has answered your question please consider it for "Accept as Solution" or if it has been helpful give it a "Thumbs Up".

Hi, When i run the pac pcf push -pp vani -f. it shows the error Error: No profiles were found on this computer. Please run 'pac auth create' to create one.

so i tried to create a authentication profile.

I am not sure how to find the common data service organization URL, Please could you let me know how will find it?

Thanks 

To create a profile the command line command is

 

pac auth create --url https://Url_including_.dynamics.com bit for instance https://testinstance.crm11.dynamics.com but it could be org123srs2.crm4.dynamics.com if you are using a powerapp.

 

that will popup the login screen and allow you login and create your credentials which will then be cached for further use until they change or expire.

---
If this post has answered your question please consider it for "Accept as Solution" or if it has been helpful give it a "Thumbs Up".

Thanks for the reply

I create the authentication profile using the below

PS C:\Users\vani\Documents> pac auth create --url https://testinstance.crm11.dynamics.com
Authentication successfully created.
Validating connection...
Connected to...
Could not connect to the CDS Organization at https://testinstance.crm11.dynamics.com.

Error: Unable to Login to Dynamics CRM

==============================

I also tried as below

PS C:\Users\vani\Documents> pac auth create --url https://metamicro123.crm11.dynamics.com
Microsoft PowerApps CLI
Version: 1.1.6+g29558dc

Error: An error occurred while sending the request.
The remote server returned an error: (502) Bad Gateway.

 

Please could you advise! Thanks

Helpful resources

Announcements

Community will be READ ONLY July 16th, 5p PDT -July 22nd

Dear Community Members,   We'd like to let you know of an upcoming change to the community platform: starting July 16th, the platform will transition to a READ ONLY mode until July 22nd.   During this period, members will not be able to Kudo, Comment, or Reply to any posts.   On July 22nd, please be on the lookout for a message sent to the email address registered on your community profile. This email is crucial as it will contain your unique code and link to register for the new platform encompassing all of the communities.   What to Expect in the New Community: A more unified experience where all products, including Power Apps, Power Automate, Copilot Studio, and Power Pages, will be accessible from one community.Community Blogs that you can syndicate and link to for automatic updates. We appreciate your understanding and cooperation during this transition. Stay tuned for the exciting new features and a seamless community experience ahead!

Summer of Solutions | Week 4 Results | Winners will be posted on July 24th

We are excited to announce the Summer of Solutions Challenge!   This challenge is kicking off on Monday, June 17th and will run for (4) weeks.  The challenge is open to all Power Platform (Power Apps, Power Automate, Copilot Studio & Power Pages) community members. We invite you to participate in a quest to provide solutions in the Forums to as many questions as you can. Answers can be provided in all the communities.    Entry Period: This Challenge will consist of four weekly Entry Periods as follows (each an “Entry Period”)   - 12:00 a.m. PT on June 17, 2024 – 11:59 p.m. PT on June 23, 2024 - 12:00 a.m. PT on June 24, 2024 – 11:59 p.m. PT on June 30, 2024 - 12:00 a.m. PT on July 1, 2024 – 11:59 p.m. PT on July 7, 2024 - 12:00 a.m. PT on July 8, 2024 – 11:59 p.m. PT on July 14, 2024   Entries will be eligible for the Entry Period in which they are received and will not carryover to subsequent weekly entry periods.  You must enter into each weekly Entry Period separately.   How to Enter: We invite you to participate in a quest to provide "Accepted Solutions" to as many questions as you can. Answers can be provided in all the communities. Users must provide a solution which can be an “Accepted Solution” in the Forums in all of the communities and there are no limits to the number of “Accepted Solutions” that a member can provide for entries in this challenge, but each entry must be substantially unique and different.    Winner Selection and Prizes: At the end of each week, we will list the top ten (10) Community users which will consist of: 5 Community Members & 5 Super Users and they will advance to the final drawing. We will post each week in the News & Announcements the top 10 Solution providers.  At the end of the challenge, we will add all of the top 10 weekly names and enter them into a random drawing.  Then we will randomly select ten (10) winners (5 Community Members & 5 Super Users) from among all eligible entrants received across all weekly Entry Periods to receive the prize listed below. If a winner declines, we will draw again at random for the next winner.  A user will only be able to win once overall. If they are drawn multiple times, another user will be drawn at random.  Individuals will be contacted before the announcement with the opportunity to claim or deny the prize.  Once all of the winners have been notified, we will post in the News & Announcements of each community with the list of winners.   Each winner will receive one (1) Pass to the Power Platform Conference in Las Vegas, Sep. 18-20, 2024 ($1800 value). NOTE: Prize is for conference attendance only and any other costs such as airfare, lodging, transportation, and food are the sole responsibility of the winner. Tickets are not transferable to any other party or to next year’s event.   ** PLEASE SEE THE ATTACHED RULES for this CHALLENGE**   Week 1 Results: Congratulations to the Week 1 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Community MembersNumber of SolutionsSuper UsersNumber of Solutions @anandm08  23 @WarrenBelz  31 @DBO_DV  10 @Amik  19 AmínAA 6 @mmbr1606  12 @rzuber  4 @happyume  7 @Giraldoj  3@ANB 6 (tie)   @SpongYe  6 (tie)     Week 2 Results: Congratulations to the Week 2 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Community MembersSolutionsSuper UsersSolutions @anandm08  10@WarrenBelz 25 @DBO_DV  6@mmbr1606 14 @AmínAA 4 @Amik  12 @royg  3 @ANB  10 @AllanDeCastro  2 @SunilPashikanti  5 @Michaelfp  2 @FLMike  5 @eduardo_izzo  2   Meekou 2   @rzuber  2   @Velegandla  2     @PowerPlatform-P  2   @Micaiah  2     Week 3 Results: Congratulations to the Week 3 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge.   Week 3:Community MembersSolutionsSuper UsersSolutionsPower Apps anandm0861WarrenBelz86DBO_DV25Amik66Michaelfp13mmbr160647Giraldoj13FLMike31AmínAA13SpongYe27     Week 4 Results: Congratulations to the Week 4 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge.   Week 4:Community MembersSolutionsSuper UsersSolutionsPower Apps DBO-DV21WarranBelz26Giraldoj7mmbr160618Muzammmil_0695067Amik14samfawzi_acml6FLMike12tzuber6ANB8   SunilPashikanti8

Check Out | 2024 Release Wave 2 Plans for Microsoft Dynamics 365 and Microsoft Power Platform

On July 16, 2024, we published the 2024 release wave 2 plans for Microsoft Dynamics 365 and Microsoft Power Platform. These plans are a compilation of the new capabilities planned to be released between October 2024 to March 2025. This release introduces a wealth of new features designed to enhance customer understanding and improve overall user experience, showcasing our dedication to driving digital transformation for our customers and partners.    The upcoming wave is centered around utilizing advanced AI and Microsoft Copilot technologies to enhance user productivity and streamline operations across diverse business applications. These enhancements include intelligent automation, AI-powered insights, and immersive user experiences that are designed to break down barriers between data, insights, and individuals. Watch a summary of the release highlights.    Discover the latest features that empower organizations to operate more efficiently and adaptively. From AI-driven sales insights and customer service enhancements to predictive analytics in supply chain management and autonomous financial processes, the new capabilities enable businesses to proactively address challenges and capitalize on opportunities.    

Updates to Transitions in the Power Platform Communities

We're embarking on a journey to enhance your experience by transitioning to a new community platform. Our team has been diligently working to create a fresh community site, leveraging the very Dynamics 365 and Power Platform tools our community advocates for.  We started this journey with transitioning Copilot Studio forums and blogs in June. The move marks the beginning of a new chapter, and we're eager for you to be a part of it. The rest of the Power Platform product sites will be moving over this summer.   Stay tuned for more updates as we get closer to the launch. We can't wait to welcome you to our new community space, designed with you in mind. Let's connect, learn, and grow together.   Here's to new beginnings and endless possibilities!   If you have any questions, observations or concerns throughout this process please go to https://aka.ms/PPCommSupport.   To stay up to date on the latest details of this migration and other important Community updates subscribe to our News and Announcements forums: Copilot Studio, Power Apps, Power Automate, Power Pages

Top Solution Authors
Users online (2,510)