cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
vidarv
Helper II
Helper II

Code not working after inserting dropdown box

I have inserted a dropdownbox in my PowerApp

vidarv_0-1642690223037.png

After I have done that my other code has stopped working

vidarv_1-1642690274171.pngvidarv_2-1642690296030.png

vidarv_3-1642690328390.png

 

vidarv_4-1642690345831.png

If I remove the dropdown box the code is working.

The PowerApp is collecting messages from Admin center. When clicking on a message your will be transformed to another screen where you can commment on the message or send the message to Planner. Behind is a sharepointlist called MessageCenterOrg.

What is wrong with my code.

Can someone please help ?

3 ACCEPTED SOLUTIONS

Accepted Solutions
RandyHayes
Super User
Super User

@vidarv 

Let's make a couple of alterations to reduce the amount of formula actions.

First one:

If(!IsBlank(SelectedBucket),
    Set(TaskAdded,Planner.CreateTask(SelectedPlan.id,TaskText.Text,{bucketId:SelectedBucket.id,dueDateTime:DueDatePicker.SelectedDate,assignments:AssignToUser.Id})),
    
    Set(TaskAdded,Planner.CreateTask(SelectedPlan.id,TaskText.Text,{dueDateTime:DueDatePicker.SelectedDate,assignments:AssignToUser.Id}))
);


Set(ShowSuccess, true);

Set(varRecord,
    With({_add: "***" & CountRows(NoteGallery.AllItems) + 1 & " - " & User().FullName & " - " & Text( Now(),DateTimeFormat.LongDateTime24,"nb-NO" ) &
            ":<br>Opprettet oppgave i Planner '"& SelectedPlan.title &"' i samling '" & SelectedBucket.name & "'<br>"},
            
        Patch(
            MessageCenterOrg,
            LookUp(MessageCenterOrg, ID=varRecord.ID),
            {Notes: varRecord.Notes & _add,
             Planner: varRecord.Planner & _add
            }
        )
    )
 )

 

Second one:

Set(varRecord,
    Patch(
        MessageCenterOrg,
        LookUp(MessageCenterOrg, ID=varRecord.ID),
        {Notes: varRecord.Notes & "***" & CountRows(NoteGallery.AllItems) + 1 & " - " & User().FullName & " - " & Text( Now(),DateTimeFormat.LongDateTime24,"nb-NO" )&
                ":<br>" & RichTextEditor.HtmlText
        }
    ) 
); 
Reset(RichTextEditor)

 

Also, at this point the varRecord setting seems consistent.  I assume that the Gallery you are coming from is based on the MessageCenterOrg datasource and that your Gallery is not adding or altering the columns of the datasource.

If that is true, then one quick thing to try - save and close your app and then go back into it.  Sometimes, when working with full record based variables, the formula editor gets confused on the schema and an exit and back in usually solves that.

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

vidarv
Helper II
Helper II

@RandyHayes Amazing, works lika a charm. Thank You so much. I have much to lear to simplify code. You are assuming right according to the gallery..
Here is a screenshot after adding some text and Planner. As you can see, when text is adding a notebokk is vsible and when adding A Planner a Planner icon become visible. This way my team will hav controll over messagecenter. 

vidarv_0-1642701909995.png

 

 

View solution in original post

RandyHayes
Super User
Super User

@vidarv 

Very good!  

If you found one of my responses helpful for resolving the problem, could you please mark that as a solution also so that others that may have similar issues can locate solutions quickly?  Thanks and glad it is all where you need it now.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

8 REPLIES 8
RandyHayes
Super User
Super User

@vidarv 

Your issue is with varRecord.  How were you setting that before?

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!
vidarv
Helper II
Helper II

Thank you for answering @RandyHayes The varRecord was set as seen in the code. How should I alter it ?

 

RandyHayes
Super User
Super User

@vidarv 

It's hard to tell from the images.  The Formulas in them are not clear (resolution is a bit small).  At a glance of them for what I could see, the formula appears generally correct.  The formula you have in the OnSelect of the Lagre button should only be doing one patch and not two, but it still doesn't appear incorrect.

 

You have shown the formulas and the red underlines, but can you please hover over the red underlines and see what the formula editor tells you the error is?  Especially over any darker/thicker red underline.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!
vidarv
Helper II
Helper II

If(!IsBlank(SelectedBucket),
    Set(TaskAdded,Planner.CreateTask(SelectedPlan.id,TaskText.Text,{bucketId:SelectedBucket.id,dueDateTime:DueDatePicker.SelectedDate,assignments:AssignToUser.Id})),
    
    Set(TaskAdded,Planner.CreateTask(SelectedPlan.id,TaskText.Text,{dueDateTime:DueDatePicker.SelectedDate,assignments:AssignToUser.Id}))
);


Set(ShowSuccess, true);

Set(varRecord,
Patch(
      MessageCenterOrg,
    varRecord,
    {Notes:varRecord.Notes & "***" & CountRows(NoteGallery.AllItems) + 1 & " - " & User().FullName & " - " &Text( Now(),DateTimeFormat.LongDateTime24,"nb-NO" )&
 ":<br>" & "Opprettet oppgave i Planner " &"'"& SelectedPlan.title &"' "&  "i samling " & "'"& SelectedBucket.name&"'"&
 "<br>"}
 )
 );
 Set(varRecord,
Patch(
      MessageCenterOrg,
    varRecord,
    {Planner:varRecord.Planner & "***" & CountRows(NoteGallery.AllItems) + 1 & " - " & User().FullName & " - " &Text( Now(),DateTimeFormat.LongDateTime24,"nb-NO" )&
 ":<br>" & "Opprettet oppgave i Planner " &"'"& SelectedPlan.title &"' "&  "i samling " & "'"& SelectedBucket.name&"'"&
 "<br>"}
 )
 )

 
Set(varRecord,
Patch(
      MessageCenterOrg,
    varRecord,
    {Notes:varRecord.Notes & "***" & CountRows(NoteGallery.AllItems) + 1 & " - " & User().FullName & " - " &Text( Now(),DateTimeFormat.LongDateTime24,"nb-NO" )&
 ":<br>" & RichTextEditor.HtmlText}
 ) 
 ); 
 Reset(RichTextEditor)

varRecord shows invalid argument type (Error),Expecting a record value instead- Else The function patch has some invalid arguments.

Filter(Split(varRecord.Notes,"***"),!IsBlank(Result))

Notes shows Invalid use of '.' else The function split has some invalid arguments

Set(varRecord,ThisItem)

can not be evaluated

vidarv
Helper II
Helper II

@RandyHayes In the other screen the navigate is Set(varRecord , ThisItem);Navigate(MesageCenter)

 

RandyHayes
Super User
Super User

@vidarv 

Let's make a couple of alterations to reduce the amount of formula actions.

First one:

If(!IsBlank(SelectedBucket),
    Set(TaskAdded,Planner.CreateTask(SelectedPlan.id,TaskText.Text,{bucketId:SelectedBucket.id,dueDateTime:DueDatePicker.SelectedDate,assignments:AssignToUser.Id})),
    
    Set(TaskAdded,Planner.CreateTask(SelectedPlan.id,TaskText.Text,{dueDateTime:DueDatePicker.SelectedDate,assignments:AssignToUser.Id}))
);


Set(ShowSuccess, true);

Set(varRecord,
    With({_add: "***" & CountRows(NoteGallery.AllItems) + 1 & " - " & User().FullName & " - " & Text( Now(),DateTimeFormat.LongDateTime24,"nb-NO" ) &
            ":<br>Opprettet oppgave i Planner '"& SelectedPlan.title &"' i samling '" & SelectedBucket.name & "'<br>"},
            
        Patch(
            MessageCenterOrg,
            LookUp(MessageCenterOrg, ID=varRecord.ID),
            {Notes: varRecord.Notes & _add,
             Planner: varRecord.Planner & _add
            }
        )
    )
 )

 

Second one:

Set(varRecord,
    Patch(
        MessageCenterOrg,
        LookUp(MessageCenterOrg, ID=varRecord.ID),
        {Notes: varRecord.Notes & "***" & CountRows(NoteGallery.AllItems) + 1 & " - " & User().FullName & " - " & Text( Now(),DateTimeFormat.LongDateTime24,"nb-NO" )&
                ":<br>" & RichTextEditor.HtmlText
        }
    ) 
); 
Reset(RichTextEditor)

 

Also, at this point the varRecord setting seems consistent.  I assume that the Gallery you are coming from is based on the MessageCenterOrg datasource and that your Gallery is not adding or altering the columns of the datasource.

If that is true, then one quick thing to try - save and close your app and then go back into it.  Sometimes, when working with full record based variables, the formula editor gets confused on the schema and an exit and back in usually solves that.

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!
vidarv
Helper II
Helper II

@RandyHayes Amazing, works lika a charm. Thank You so much. I have much to lear to simplify code. You are assuming right according to the gallery..
Here is a screenshot after adding some text and Planner. As you can see, when text is adding a notebokk is vsible and when adding A Planner a Planner icon become visible. This way my team will hav controll over messagecenter. 

vidarv_0-1642701909995.png

 

 

RandyHayes
Super User
Super User

@vidarv 

Very good!  

If you found one of my responses helpful for resolving the problem, could you please mark that as a solution also so that others that may have similar issues can locate solutions quickly?  Thanks and glad it is all where you need it now.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

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 (3,575)