PowerApp Screen – OnVisible Event Not Firing

While working on one PowerApp, I observed that the code written in first screen “OnVisible” event is not executing which means OnVisible event is not firing. I found couple of workarounds for this issue.

Workaround 1: Add a welcome screen with a simple button which will navigate to your actual screen.

Workaround 2: If you don’t like the Idea of having a welcome screen, you can use this one. Place a timer control on the screen (make it invisible and sent to back) and write the code in “OnTimerEnd” event.

Properties for Timer Control

OnTimeEnd event

Hope it helps to solve this issue.

How to use Virtual Agent (bot)

Recently for one of our customer I developed a Virtual Agent (bot) which will ask basic details like First Name, Last Name, Company Name and Email Id for the Portal Registration and at the end it will save the data in CDS. Follow the below steps to develop a simple bot

Step 1: Create a new trail instance here (as of now Virtual Agent preview is only available for United States region)

Step 2: After the trail instance is created, create an Entity to save the portal registrations data. In my example, I created an entity called “Portal Registration” with the below fields

  1. Last Name
  2. First Name
  3. Company Name
  4. Email Id

Step 3: Create a MS Flow. We will integrate this flow with bot in the next steps to save the data in “Portal Registration” entity. Please note, you have to create a Flow in “Common Data Services Default Solution”, otherwise bot can’t access this Flow.

The trigger for the Flow should be “When a HTTP request is received”.

The Request Body in this example should be like below.

“type”: “object”,
“properties”: {
“lastname”: {
“type”: “string”
“firstname”: {
“type”: “string”
“companyname”: {
“type”: “string”
“email”: {
“type”: “string”

Step 4: Go to your Virtual Agent Preview instance (https://va.ai.dynamics.com) and create a bot. Use “Bots panel” button

on the top right navigation to create a new bot. Provide bot’s name and click on Create.

Step 5: After bot is created, you can add your own custom Topics. You will have some predefined Topics available once the bot is created which you can use for your reference.

In my case, I created “Portal Registration” Topic. You have to specify some Trigger phrases to trigger a particular topic. In this example, when ever you enter any of the phrase that I specified in the below screenshot, the bot will choose my topic and start the conversation which we will setup in next steps.

Step 6: Once you click on Edit button, it will redirect to actual page where you should develop your conversation. Use “Bot Says” action to ask a question to the user and “User Responses” action to get the answer from the user, finally capture the user response in a parameter for further use. Repeat this for rest of the questions (First Name, Company Name and Email Id)

Step 7: At the end, we have to save this information in CDS. For this requirement we have to integrate a MS Flow with the bot. Use “Action” action and select the Flow that we created in Step 3 and pass the parameters to MS Flow

Step 8: At the end Deploy the bot on Demo Website and Publish it. Use the bot through URL which is generated after Publish.

Hope it will give you basic idea on how to use bot with MS Flow.

How to remove unwanted PowerApp parameters in MS Flow

Recently I worked on one PowerApp which will call the MS Flow to perform my action. Initially, I created a Flow with 8 parameters and passing the values from PowerApp but at the end I realized that I can perform my action with 6 parameters in MS Flow, so decided to delete the extra 2 parameters as my PowerApp is expecting the value for those parameters which are not required. There is no direct approach to delete the parameters in Flow, I think Microsoft still working on this issue but there is workaround to do this


  1. Delete the PowerApp trigger on the top of the MS Flow and you see a message box “This step and associated dynamic content will be deleted from this flow.”
  2. Click on OK (It won’t affect the actions in your flow)
  3. Add the PowerApp trigger again, this should give you a chance to provide a new dynamic content.

I know it’s not a best approach but as of now we don’t have any better way to resolve this issue. Hope it helps….

Call Microsoft Flow from Custom Ribbon Button

In one of my previous blog I mentioned how to use on demand flow within MS CRM. But we have some limitations with that approach

  1. we can’t apply Enable rules on the Flow button as it is OOB context menu which generates dynamically based on the number of flows.
  2. we can’t restrict a call to Flow to check the conditions whether Flow needs to run or not, I mean we can’t apply our conditions before a request goes to Flow.

the solution for the above problems is to call the Flow from custom ribbon button. To call a Flow from ribbon button, we have to create a flow on “HTTP Request” trigger. In my example I am creating a contact with First Name and Last Name fields and passing the parameters from ribbon button (as of now I am passing some constant values from my javascript). Here is the step by step process to do this

Step 1: Create a Flow with HTTP Request with proper “Request Body JSON schema” (use sample payload option to generate the schema)

Step 2: Add “Create a new record (Dynamics)” action to create a new Contact in CRM.

Step 3: Add a Response action at the end to send the response back to CRM and Save the Flow .

Step 4: Once your flow is created you will see the URL in the “HTTP Request” trigger. Use “HTTP POST URL” to trigger the Flow from ribbon button action (javascript).

Step 5: Create a ribbon button in CRM and call the below function from the ribbon button.

with this approach you can add all your validations in the java script and call the Flow once the conditions met, this way we can reduce lot of unnecessary calls to Flow. We can pass whole record context to Flow if needed. Hope it is interesting 🙂

Auto Number PowerApp Custom Control

I developed my first PowerApp custom control which will generate Auto Number based on the format that you specified. I find this always a missing functionality from MS to generate Auto Number based on the data in a record. I thought it would be useful tool for lot of customers. The following are some details about my control.

  1. You need to specify the AutoNumber format in the following format
  2. Use {Something} if you want include constant string in the Auto Number like Prefix or Suffix. For ex: {ACC}
  3. Use [fieldname] if you want to include a field value in the Auto Number. For ex: [accountnumber]
  4. Use [fieldname(fieldname)] if you want to include a field value from the look up field. For ex: [transactioncurrencyid(isocurrencycode)]
  5. You can use any separator in between.
  6. For ex if you provide in this format {ACC}-[accountnumber]-[parentaccountid(numberofemployees)] , the output would be ACC-1001-200 (based on the values of the particular record).

You can find the source code here

PCF Gallery link here