Vue normale

Il y a de nouveaux articles disponibles, cliquez pour rafraîchir la page.
À partir d’avant-hierFlux principal

Clone a single record from Command bar using Power FX Formulas

Power Fx is a low-code language that makers can work with directly in an Excel-like formula bar or Visual Studio Code text window.

Power Fx are the main coding language in Canvas apps and have been extended to Model Driven apps as well to be used from the Command bar to execute actions in addition to JavaScript, and is used as well as a new column type similar to calculated columns.

In this quick article we will see how we can clone a contact record directly by clicking a button on the form command bar:

  1. Add your model driven app in a solution and open
  2. Navigate to Pages->Contacts View-> Click the 3 horizontal dots and choose Edit Command Bar ->Edit

3. Select Main Form and click Edit

4. Select New -> New Command from the commands left Navigation.

5. You will be promoted with a question whether you want to create a Power FX command or JavaScript for Power Fx it will need to create a component library to enable you to use the Power FX formulas -> Choose Power FX and click Next

6. Give you new command a label “Clone Contact“, in the Action shows to run Formula and you will see the Formula Bar is opened by default on the On Select Event, you can also change the visibility to run based on a formula

7. For the actual command we need to use the very popular Patch function and the key thing here is how to access the fields in the current form so it is very easy using the below expression:

Self.Selected.Item

This expression gives you access to the current object and then you can access the fields easy as

Self.Selected.Item.'Last name'

The below command will be cloning the first name, last name and company name which is a lookup to the account table.

Patch(Contacts,Defaults(Contacts),{'First name':Concatenate("copy",Self.Selected.Item.'First name')},{'Last name':Self.Selected.Item.'Last name'},{
    'Company':Self.Selected.Item.'Company'
})

Note:

I could not make it work till now using Composite/Polymorphic Look ups like customer!

It is working perfectly in less than 10 minutes you could clone a record very easily!

Happy Low Code Development!

References:

https://learn.microsoft.com/en-us/power-apps/maker/model-driven-apps/commanding-use-powerfx

DataVerse Tip #7: Can’t delete a Table because of dependency of Type App Action

I came around an interesting topic in the community forums where the issue was about the inability to delete a created table because of the dependency of type ‘app action’.

What is app action?

App action is created when you create a new command bar button using Power FX Formula and a component library gets created.

To demonstrate what this means follow these steps:

  1. Create a table called Table 1
  2. Create a model driven app called Test Dependencies Issues.
  3. Add the table to your Model Driven app by adding a new page.
  4. Click Edit command Bar on your Table
  5. Add a new button and name it Test Command.
  6. When you choose to create a new command of type powerFx formula you get the below message which means a new component library will be created for your button, Save an publish.

7. Now you can go to dependencies and check there will be a dependency on the Model Driven app and this is easy by removing button and the table from the model driven app and another dependency which is the app action.

How to get rid of this dependency?

This dependency is not available through the UI and so you need to use the Rest Builder tool to identify the Id highlighted in the above image and then delete it using the rest builder tool.

  1. Open the Dataverse Rest Builder tool of the XRM toolbox, Perform a Retrieve Multiple Request on the Primary Entity appaction and click create request to view the results.

2. Identify the Id of the app action related to your table and then using the Delete action on the Dataverse Rest Builder , delete the app action and hence you delete the dependency.

Kudos goes to Prakash4691 and his awesome topic answer here.

Reference for the entity app action is here

miraghaly

DataVerse Tip #7: Can’t delete a Table because of dependency of Type App Action

I came around an interesting topic in the community forums where the issue was about the inability to delete a created table because of the dependency of type ‘app action’.

What is app action?

App action is created when you create a new command bar button using Power FX Formula and a component library gets created.

To demonstrate what this means follow these steps:

  1. Create a table called Table 1
  2. Create a model driven app called Test Dependencies Issues.
  3. Add the table to your Model Driven app by adding a new page.
  4. Click Edit command Bar on your Table
  5. Add a new button and name it Test Command.
  6. When you choose to create a new command of type powerFx formula you get the below message which means a new component library will be created for your button, Save an publish.

7. Now you can go to dependencies and check there will be a dependency on the Model Driven app and this is easy by removing button and the table from the model driven app and another dependency which is the app action.

How to get rid of this dependency?

This dependency is not available through the UI and so you need to use the Rest Builder tool to identify the Id highlighted in the above image and then delete it using the rest builder tool.

  1. Open the Dataverse Rest Builder tool of the XRM toolbox, Perform a Retrieve Multiple Request on the Primary Entity appaction and click create request to view the results.

2. Identify the Id of the app action related to your table and then using the Delete action on the Dataverse Rest Builder , delete the app action and hence you delete the dependency.

Kudos goes to Prakash4691 and his awesome topic answer here.

Reference for the entity app action is here

❌
❌