cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
justinridgebd
Frequent Visitor

Setting Field Labels dynamically in a Powerapps Form

Hi there

 

I have a Dataverse table called "Clients" with the following fields.

 

Client Name - Text

ChecklistItem 1 - Text

ChecklistItem 2 - Text

ChecklistItem 3 - Text

 

The, I have another Dataverse table called "Items" with the following fields

 

Client Name (Lookup to Clients folder)

Check 1 - Yes/No

Check 2 - Yes/No

Check 3 - Yes/No

 

 

I wanting to know if it's possible to set the Label of Check1, Check2 and Check3 to be the value of ChecklistItem 1, 2, 3 in the Clients table (corresponding to the client lookup chosen for the record).

 

Obviously, I can't change the name of the field names as this would affect the whole table and not just the selected record.

 

If there is a solution via Javascript, please could you give me step by step instructions, (as my Javascript knowledge isn't that great)

5 REPLIES 5
rubin_boer
Super User
Super User

hi @justinridgebd 

 

This will help or give direction;

i assume 3 columns in both tables and should it be more or dynamic you can use ForAll 

 

add a dropdown to your dorm where the user can select the client

now consider the following

DataSource(_clients) two entries with the client name some name 1 and some name 2:

ClearCollect(
    _clients,
    {
        ClientName: "some name 1",
        'ChecklistItem 1': "Some item 1",
        'ChecklistItem 2': "Some item 2",
        'ChecklistItem 3': "Some item 3"
    },
    {
        ClientName: "some name 2",
        'ChecklistItem 1': "Another item 1",
        'ChecklistItem 2': "Another item 2",
        'ChecklistItem 3': "Another item 3"
    }
)

 

the dropdown has this DataSource with the Primary text the ClientName

 

OnChange of the dropdown add the following formula

ClearCollect(
    _items,
    AddColumns(
        Filter(
            _clients,
            ClientName = Self.Selected.ClientName
        ),
        "Check Items",
        'ChecklistItem 1' & "," & 'ChecklistItem 2' & "," & 'ChecklistItem 3'
    )
)

 

add a gallery and set the Items = Split(First(_items).'Check Items',",")

add a label and a toggle swtich to the gallery, set he label's Text = ThisItem.Result

 

The result

columns as labels.gif

Hope it helps,

R 

 

hey there if you liked the post give it a thumbs up, and if it solved your question please accept it as a solution.
justinridgesa
Regular Visitor

Hi Rubin.

 

Thanks for your response.

I should have made it clear that I am actually using a Model-driven app and not a Canvas app.

 

As you can see below, I have a Client Form (and Dataverse Table) with my Client Names and the 5 checklist items for each client (Text fields).

 

In the Submissions Form I have the Client Name (lookup to the Clients table).

I also have 5 fields for the 5 checklist items (These are Yes/No fields)

 

As you'll see from the pic below, in the Submissions form there are the checklists.

What I want to be able to do is set the label of each checklist to be equal to the Value of the corresponding checklist item in the Clients table/form.

 

Client Form

justinridgesa_1-1645945422068.png

 

Submissions Form

justinridgesa_0-1645945399995.png

 

My gut says this isn't achievable through this method, but if you have any ideas on how to achieve the same kind of thing, please let me know

 

Thank you!

Hi @justinridgesa ,

 

Are you trying to say that if you select 'Check1' as true then it label should change from 'Check1' to 'Sandals' ?

justinridgesa
Regular Visitor

Hi Ethan (Replying from a different account)

 

No, the label should change to 'Sandals' regardless of whether is set to True/False.

So, I basically am wanting to pull the checklist data (From clients) into the 'Submissions' entity - to the corresponding fields.
The challenge is that these values will change from Submission to Submission (because each submission references a different client from 'Clients'.

 

Hope that makes sense

Hi @justinridgesa ,

 

This is quite challenging, I feel you should have some kind of sub-grid that holds values for such Checklist items as this will save Name of Item and Toggle Value in backend.

 

If you want just frontend for temporary basis (since Labels are not stored in database), you can use JS to achieve this.

// To change the Label of Control/Field
//This is basic label changing code.
formContext.getControl("new_check1").setLabel("Test Renamed");

 

For getting Clients checklist items,

You will need to use 'retreiveRecord' and pass fields name that you want.

Then loop the result with you list of Labels of CheckList items from 'Submission' entity and set each label accordingly.

Note: I don't recommend this since label won't be stored and can be altered if queue is disturbed. This can only be effective if CheckList Items on both entities are constant (i.e. won't change) and require temporary knowledge of what each checklist stands for.

 

 

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (6,451)