Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Building Power Apps
Answered

Error with collection

(1) ShareShare
ReportReport
Posted on by 237
Hi all, 
 
I'm having issues and wondered if there's anything obvious? the varSelectDate is from the on change of my date picker,  
 
If(ctxLoadPeople,
//Load People
ClearCollect(colPeople,
AddColumns(Sort(EngineerNames,FullName) As Contact,
Zone,
"People",
PersonaImage,
    If(!IsBlank(Contact.EntitiyImage),Substitute(JSON(Contact.EntitiyImage.Value,JSONFormat.IncludeBinaryData),"""","")),
 
    Initials,
    Mid(Contact.'First Name',1,1) & Mid(Contact.'Last Name',1,1)
    )
);
UpdateContext({ctxLoadPeople:false});
 
If(ctxLoadDaySlots,
// Create Day Slots
ClearCollect(
    colDaySlots,
    ForAll(
        colPeople As Person,
        {
            Person: Person,
            Days: ForAll(
                Sequence(DaysinRange) As Day,
                {
                    PersonId: Person.FullName,
                    Day: Day.Value,
                    Zone: $"{Day.Value}|{Person.FullName}"
                }
            )
        }
    )
);
UpdateContext({ctxLoadDaySlots:false});
 
If(ctxTaskEvent,
ClearCollect(
    ColTasks,
    AddColumns(
        ProjectTasks,
        TaskName,JobDetails,
        Zone,
        If(IsBlank('Assigned To'),
        "Unassigned",
        $"{DateDiff(VarSelectedDate,'Due Date',TimeUnit.Days)+1}|{'Assigned To'.Contact}"
       
        ),
         Edited,false
    )
);
UpdateContext({ctxTaskEvent:false});
);
 
 
  • Verified answer
    stampcoin Profile Picture
    588 on at
    Error with collection
    I am heading for lunch... here is an reference for you.
    NewColumn, $"{DateDiff("2025-04-16","2025-04-19",TimeUnit.Days)+1}|{'Status (Contacts)'.Active}"
     
    'Assigned To'.Contact, is this correct format ( didn't watch the video...).
    the format should be columnname(tableName).value ( see my example), or some property you can refer to.
  • jsmith87 Profile Picture
    237 on at
    Error with collection
     thank you that's working now, the only issue is that Contacts are a table i believe and the dates need to be changed to text. I don't suppose you'd be ok with a call to help me resolve this issue? if that's ok i'd really appreciate it, i'm sure it's something you'd be able to resolve in seconds 
     
    If(ctxLoadPeople,
    //Load People
    ClearCollect(colPeople,
    AddColumns(Sort(EngineerNames,FullName) As Contact,
    Zone,
    "People",
    PersonaImage,
        If(!IsBlank(Contact.EntitiyImage),Substitute(JSON(Contact.EntitiyImage.Value,JSONFormat.IncludeBinaryData),"""","")),
     
        Initials,
        Mid(Contact.'First Name',1,1) & Mid(Contact.'Last Name',1,1)
        )
    ));
    UpdateContext({ctxLoadPeople:false});
     
    If(ctxLoadDaySlots,
    // Create Day Slots
    ClearCollect(
        colDaySlots,
        ForAll(
            colPeople As Person,
            {
                Person: Person,
                Days: ForAll(
                    Sequence(DaysinRange) As Day,
                    {
                        PersonId: Person.FullName,
                        Day: Day.Value,
                        Zone: $"{Day.Value}|{Person.FullName}"
                    }
                )
            }
        )
    ));
     
    If(ctxTaskEvent,
    ClearCollect(
        ColTasks,
        AddColumns(
            ProjectTasks,
            TaskName,"JobDetails",
            Zone,
           
            If(IsBlank('Assigned To'),
            "Unassigned",
    $"{DateDiff("2025-04-16","2025-04-19",TimeUnit.Days)+1}|{"John Doe"}"
         
            ),
             Edited,false
        )
    );
    UpdateContext({ctxTaskEvent:false});
    );
  • Suggested answer
    stampcoin Profile Picture
    588 on at
    Error with collection
    some tips:
    1. make sure VarSelectedDate,'Due Date' both are date type, you can add a label, and assign the label text= VarSelectedDate, another label, assign text='Due date'. the purpose is to identify both have the correct data
    2. identify 'Assigned To'.Contact} make sure it is text type value.
    3. another easy way is like this:
      $"{DateDiff("2025-04-16","2025-04-19",TimeUnit.Days)+1}|{"John Doe"}"
    then you will know which part has problem.
    feel free if you need more help.
  • jsmith87 Profile Picture
    237 on at
    Error with collection
    Hi yes, i'm on the third video all is working as it should till this particular item
  • ronaldwalcott Profile Picture
    3,497 on at
    Error with collection
    Did you start from the first video to build it and follow the Github notes?
  • jsmith87 Profile Picture
    237 on at
    Error with collection
    I think it's certainly my variable, but don't know how to resolve. When i hover over the error i get this 
     
  • jsmith87 Profile Picture
    237 on at
    Error with collection
    Hi Stampcoin, 
     
    Thanks for the tips, still no joy (it's certainly me!)
     
    following your advice I went back to my dataverse table and added a date column. Which I have named Due date. So with varSelectedDate coming from my data picker and having a dataverse table column with date fomat they should be both the same however i am getting the below error. 
     
    Also regarding JobDetails to TaskName. do you mean TaskName,"TaskName",JobDetails,"JobDetails" ?
     
    I honestly don't know, I thought following a video step by step to enhance my knowledge would be a good way to learn. I was wrong.... in my dataverse fields i have:
     
    I think what the video is trying to achieve is that if in the dataverse table someone's name is in the assigned to and there's a date it will combine them both with | between the name and date. Does this help at all?
     
     
  • Suggested answer
    stampcoin Profile Picture
    588 on at
    Error with collection
     
    1.  I think in your code, you assigned JobDetails to TaskName. do you mean TaskName, "TaskName",JobDetails,"JobDetails" ?
    2.  $"{DateDiff(VarSelectedDate,'Due Date',TimeUnit.Days)+1}|{'Assigned To'.Contact}"
      1. {DateDiff(VarSelectedDate,'Due Date',TimeUnit.Days)+1}, looks correct,you have to make sure VarSelectedDate and 'Due Date' is the same date type, this one return a integer.
      2.  'Assigned To'.Contact, this part you have to make sure it is a text.
    try those checks first.
    good luck.
  • jsmith87 Profile Picture
    237 on at
    Error with collection
    Hi, 
     
    from watching the video i'm following, https://www.youtube.com/watch?v=wkHvjusgLEE&t=326s the part is 5:14 
     
    what i'm trying to achieve is to create a unique ID with the first part being a date from my dataverse column Due Date and then a | with the second part being a persons name so i should have something like
     
    28/01/2025|John Smith
     
    the thing i can't figure out from the video is where he's got that variable from. I only have a date picker and a label which have anything to do with date. I'll add the code for them further down. 
     
    $"{DateDiff(VarSelectedDate,'Due Date',TimeUnit.Days)+1}|{'Assigned To'.Contact}"
     
     
    from label
    Text(DateAdd(DatePickerCanvas1.SelectedDate,ThisItem.Value-1,TimeUnit.Days),DateTimeFormat.ShortDate)
     
    from date picker
    Select(fnLoadTasks_2)
  • ronaldwalcott Profile Picture
    3,497 on at
    Error with collection
    Assuming that the two values in the DateDiff are correctly formatted dates.
    Datediff returns a number. Thought it would convert it to text. Try adding a Text function around it to convert it to text 

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,631 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,976 Most Valuable Professional

Leaderboard