web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / varpersonalinfolookup ...
Power Apps
Unanswered

varpersonalinfolookup before it gets defined?

(0) ShareShare
ReportReport
Posted on by 16

I've created some code but getting lots of errors and believe it's down to the VarPersonalLookUp not being defined, not sure what it meant by this, see my code below:

 

Any help it greatly appreciated.

 

KevDaRed_0-1633327072389.png

 

Categories:
I have the same question (0)
  • WarrenBelz Profile Picture
    153,117 Most Valuable Professional on at

    Hi @KevDaRed ,

    Can you please post all of that code including the bit following in a Text box (the </> icon above).

  • KevDaRed Profile Picture
    16 on at

    /*User personal details*/
    Set(
    varEmail,
    User().Email
    );
    Set(
    varFullname,
    User().FullName
    );
    LoadData(
    colPersonalInfo,
    "colPersonalInfo",
    true
    );
    If(
    Connection.Connected,
    Refresh('End of Shift New Report');
    Refresh('End of Shift - Users');
    Set(
    varPersonalInfoLookUp,
    LookUp(
    'End of Shift - Users',
    varEmail = Email
    )
    );

    /*Check to see if the collection details are same as SP list*/
    If(
    varEmail in 'End of Shift - Users'.Email And CountRows(colPersonalInfo) <> 0 And (varPersonalInfoLookUp.Title <> First(colPersonalInfo).Title Or varPersonalInfoLookUp.Email <> First(colPersonalInfo).Email Or varPersonalInfoLookUp.Linemanageremailaddress <> First(colPersonalInfo).Linemanageremailaddress Or varPersonalInfoLookUp.IMDMemailaddress <> First(colPersonalInfo).IMDMemailaddress Or varPersonalInfoLookUp.TMEemailaddress <> First(colPersonalInfo).TMEemailaddress,
    /*If not collection details are patched to SP List*/
    ,Patch(
    'End of Shift - Users',
    LookUp(
    'End of Shift - Users',
    Email = varEmail
    ),
    {
    Title: First(colPersonalInfo).Title,
    Email:First(colPersonalInfo).Email,
    Linemanageremailaddress: First(colPersonalInfo).Linemanageremailaddress,
    IMDMemailaddress: First(colPersonalInfo).IMDMemailaddress,
    TMEemailaddress: First(colPersonalInfo).TMEemailaddress
    }
    );
    SaveData(colPersonalInfo, "colPersonalInfo"),
    /*Check to see if collection is empty but details are in SP list*/
    CountRows(colPersonalInfo) = 0 And varEmail in 'End of Shift - Users'.Email,
    /*If so information is taken from SP list and put into collection*/
    Set(
    varPersonalInfoLookUp,
    LookUp(
    'End of Shift - Users',
    varEmail = Email
    )
    );
    ClearCollect(
    colPersonalInfo,
    {
    Title: First(colPersonalInfo).Title,
    Email:First(colPersonalInfo).Email,
    Linemanageremailaddress: First(colPersonalInfo).Linemanageremailaddress,
    'IMDM email address': First(colPersonalInfo).IMDMemailaddress,
    TMEemailaddress: First(colPersonalInfo).TMEemailaddress
    }
    );
    SaveData(colPersonalInfo, "colPersonalInfo"),
    //Check to see if collection has details in but SP List has no record of user
    Not(varEmail in 'End of Shift - Users'.Email) And CountRows(colPersonalInfo) <> 0,
    //If so the collection is cleared meaning user has to create account again
    Clear(colPersonalInfo);
    SaveData(colPersonalInfo, "colPersonalInfo")
    );
    LoadData(
    SubmissionFormCol,
    "SubmissionFormCol",
    true
    );

    /*Check to see if there are pending offline submissions*/
    If(
    CountRows(SubmissionFormCol) <> 0,
    /*If so loop is started to collect all submissions into SP list and emails are sent to relevant addresses*/
    ClearCollect(SubmissionFormColCount, SubmissionFormCol);
    ForAll(
    SubmissionFormCol,
    Collect(
    'End of Shift New Report',
    First(SubmissionFormColCount)
    );
    Remove(SubmissionFormColCount, First(SubmissionFormColCount));

    Mail.SendEmailV3(DataCardValue27.Text, "End of Shift Report", "<Table width='100%' Align='center' style='border-collapse: collapse'>
    <tr>
    <td style='align: left; width: 45px;'><img src='https://i.ibb.co/kGxmCXm/DF-Logo-Black.png' width='59' height='45' /></td>
    <td style='font-weight: bold; font-size: 28px; font-style: normal; line-height: 34px; text-align: center; align: center; vertical-align: bottom;'>New End of Shift Report</td>
    </tr>
    </Table>
    <div style='width:100%;align:center;background-color:#f3f3f3;'>
    <hr style='background-color: #742774; color: #742774; height: 3px; width: 100%; vertical-align:top;' />
    <p style='position: absolute; font-style: normal; font-weight: 600; font-size: 20px; line-height: 24px; color: #000000;'>Your End of Shift report has been submitted succesfully.</p>
    <br /><br />
    <br>
    <br>
    <Table style='border-collapse: collapse;' border='1' width='45%' rules='all' cellpadding='3' Align='center' bgcolor='#f3f3f3'>
    <tr>
    <td style='text-align: left; font-style: normal; font-weight: bold; font-size: 20px; line-height: 24px; padding-right: 10px;' width='40%'>Shift Type</td>
    <td style='font-style: normal; font-weight: 600; font-size: 20px; line-height: 24px; padding-left: 10px;'>"&ThisRecord.Title&"</td>
    </tr>
    <tr>
    <td style='text-align: left; font-style: normal; font-weight: bold; font-size: 20px; line-height: 24px; padding-right: 10px;' width='40%'>Shift start date</td>
    <td style=' font-style: normal; font-weight: 600; font-size: 20px; line-height: 24px; padding-left: 10px;'>"&ThisRecord.Shiftstartdate&"</td>
    </tr>
    <tr>
    <td style='text-align: left; font-style: normal; font-weight: bold; font-size: 20px; line-height: 24px; padding-right: 10px;' width='40%'>Team leader on shift</td>
    <td style=' font-style: normal; font-weight: 600; font-size: 20px; line-height: 24px; padding-left: 10px;'>"&ThisRecord.Teamleaderonshift&"</td>
    </tr>
    <tr>
    <td style='text-align: left; font-style: normal; font-weight: bold; font-size: 20px; line-height: 24px; padding-right: 10px;' width='40%'>Location</td>
    <td style='font-style: normal; font-weight: 600; font-size: 20px; line-height: 24px; padding-left: 10px;'>"&ThisRecord.Location&"</td>
    </tr>
    <tr>
    <td style='text-align: left; font-style: normal; font-weight: bold; font-size: 20px; line-height: 24px; padding-right: 10px;' width='40%'>Planned start date</td>
    <td style='font-style: normal; font-weight: 600; font-size: 20px; line-height: 24px; padding-left: 10px;'>"&DateValue1.SelectedDate&"</td>
    </tr>
    <tr>
    <td style='text-align: left; font-style: normal; font-weight: bold; font-size: 20px; line-height: 24px; padding-right: 10px;' width='40%'>Planned start time</td>
    <td style='font-style: normal; font-weight: 600; font-size: 20px; line-height: 24px; padding-left: 10px;'>"&HourValue1.Selected.Value&":"&MinuteValue1.Selected.Value&"</td>
    <tr>
    <td style='text-align: left; font-style: normal; font-weight: bold; font-size: 20px; line-height: 24px; padding-right: 10px;' width='40%'>Actual start date</td>
    <td style=' font-style: normal; font-weight: 600; font-size: 20px; line-height: 24px; padding-left: 10px;'>"&DateValue9.SelectedDate&"</td>
    </tr>
    <tr>
    <td style='text-align: left; font-style: normal; font-weight: bold; font-size: 20px; line-height: 24px; padding-right: 10px;' width='40%'>Actual start time</td>
    <td style=' font-style: normal; font-weight: 600; font-size: 20px; line-height: 24px; padding-left: 10px;'>"&HourValue9.Selected.Value&":"&MinuteValue9.Selected.Value&"</td>
    </tr>
    <tr>
    <td style='text-align: left; font-style: normal; font-weight: bold; font-size: 20px; line-height: 24px; padding-right: 10px;' width='40%'>Planned end date</td>
    <td style=' font-style: normal; font-weight: 600; font-size: 20px; line-height: 24px; padding-left: 10px;'>"&DateValue6.SelectedDate&"</td>
    </tr>
    <tr>
    <td style='text-align: left; font-style: normal; font-weight: bold; font-size: 20px; line-height: 24px; padding-right: 10px;' width='40%'>Planned end time</td>
    <td style=' font-style: normal; font-weight: 600; font-size: 20px; line-height: 24px; padding-left: 10px;'>"&HourValue6.Selected.Value&":"&MinuteValue6.Selected.Value&"</td>
    </tr>
    <tr>
    <td style='text-align: left; font-style: normal; font-weight: bold; font-size: 20px; line-height: 24px; padding-right: 10px;' width='40%'>Actual end date</td>
    <td style=' font-style: normal; font-weight: 600; font-size: 20px; line-height: 24px; padding-left: 10px;'>"&DateValue7.SelectedDate&"</td>
    </tr>
    <tr>
    <td style='text-align: left; font-style: normal; font-weight: bold; font-size: 20px; line-height: 24px; padding-right: 10px;' width='40%'>Actual end time</td>
    <td style=' font-style: normal; font-weight: 600; font-size: 20px; line-height: 24px; padding-left: 10px;'>"&HourValue7.Selected.Value&":"&MinuteValue7.Selected.Value&"</td>
    </tr>
    <tr>
    <td style='text-align: left; font-style: normal; font-weight: bold; font-size: 20px; line-height: 24px; padding-right: 10px;' width='40%'>Planned work</td>
    <td style=' font-style: normal; font-weight: 600; font-size: 20px; line-height: 24px; padding-left: 10px;'>"&ThisRecord.Plannedwork&"</td>
    </tr>
    <tr>
    <td style='text-align: left; font-style: normal; font-weight: bold; font-size: 20px; line-height: 24px; padding-right: 10px;' width='40%'>Was the work completed</td>
    <td style=' font-style: normal; font-weight: 600; font-size: 20px; line-height: 24px; padding-left: 10px;'>"&ThisRecord.Hastheworkbeencompleted&"</td>
    </tr>
    <tr>
    <td style='text-align: left; font-style: normal; font-weight: bold; font-size: 20px; line-height: 24px; padding-right: 10px;' width='40%'>Have you completed WAIFS</td>
    <td style=' font-style: normal; font-weight: 600; font-size: 20px; line-height: 24px; padding-left: 10px;'>"&ThisRecord.HaveyoucompletedWAIFS&"</td>
    </tr>
    <tr>
    <td style='text-align: left; font-style: normal; font-weight: bold; font-size: 20px; line-height: 24px; padding-right: 10px;' width='40%'>Time on tools (Duration in hours and minutes)</td>
    <td style=' font-style: normal; font-weight: 600; font-size: 20px; line-height: 24px; padding-left: 10px;'>"&TimeOnToolsHour.Selected.Value&":"&TimeOnToolsMins.Selected.Value&"</td>
    </tr>
    <tr>
    <td style='text-align: left; font-style: normal; font-weight: bold; font-size: 20px; line-height: 24px; padding-right: 10px;' width='40%'>Non-Time on tools (Duration in hours and minutes)</td>
    <td style=' font-style: normal; font-weight: 600; font-size: 20px; line-height: 24px; padding-left: 10px;'>"&NonTimeOnToolsHour.Selected.Value&":"&NonTimeOnToolsMins.Selected.Value&"</td>
    </tr>
    <tr>
    <td style='text-align: left; font-style: normal; font-weight: bold; font-size: 20px; line-height: 24px; padding-right: 10px;' width='40%'>Comments</td>
    <td style=' font-style: normal; font-weight: 600; font-size: 20px; line-height: 24px; padding-left: 10px;'>"&ThisRecord.Comments&"</td>
    </tr>
    </Table>
    <br />
    <br /><br />
    </div>
    <div style='background-color:#742774;text-align:center;font-style:normal;font-weight:bold;font-size:18px;line-height:22px;color:#ffffff'><br />This App was created by the Digital Factory. Visit us at <a href='https://nrdigital.co' style='color:#ffffff;'>https://nrdigital.co/</a> to find out more about what we do.<br /><br />
    </div>", true);

    //SubmitForm(Form2);
    ResetForm(Form2);
    Notify(
    "Form successfully submitted",
    Success
    )
    );
    Clear(SubmissionFormCol);
    SaveData(
    SubmissionFormCol,
    "SubmissionFormCol"
    )))

  • KevDaRed Profile Picture
    16 on at

    The errors are from

     

    /*Check to see if the collection details are same as SP list*/  

     

    down to

     

    SaveData(colPersonalInfo, "colPersonalInfo")
    );

     

    All other parts of the code seem good.

  • WarrenBelz Profile Picture
    153,117 Most Valuable Professional on at

    Hi @KevDaRed ,'

    You might have left the email out - I was referring to code relevant to the error function. Anyway, I parsed it as below and there were some bracket and commas errors. Note that I free-typed this in Notepad without the benefit of red lines, but I am sure you will get the idea. Also please post any code in a code box as I have below and if possible parse it.

    *User personal details*/
    Set(
     varEmail,
     User().Email
    );
    Set(
     varFullname,
     User().FullName
    );
    LoadData(
     colPersonalInfo,
     "colPersonalInfo",
     true
    );
    Set(
     varPersonal,
     First(colPersonalInfo)
    );
    If(
     Connection.Connected,
     Refresh('End of Shift New Report');
     Refresh('End of Shift - Users');
     Set(
     varPersonalInfoLookUp,
     LookUp(
     'End of Shift - Users',
     varEmail = Email
     )
     );
     If(
     varEmail in 'End of Shift - Users'.Email && 
     CountRows(colPersonalInfo) > 0 &&
     (
     varPersonalInfoLookUp.Title <> varPersonal.Title || 
     varPersonalInfoLookUp.Email <> varPersonal.Title.Email ||
     varPersonalInfoLookUp.Linemanageremailaddress <> varPersonal.Linemanageremailaddress || 
     varPersonalInfoLookUp.IMDMemailaddress <> varPersonal.IMDMemailaddress || 
     varPersonalInfoLookUp.TMEemailaddress <> varPersonal.TMEemailaddress
     ), //first if argument
     Patch(
     'End of Shift - Users',
     {Email:varEmail},
     {
     Title: varPersonal.Title,
     Email:varPersonal.Email,
     Linemanageremailaddress: varPersonal,
     IMDMemailaddress: varPersonal.IMDMemailaddress,
     TMEemailaddress: varPersonal.TMEemailaddress
     }
     );
     SaveData(colPersonalInfo, "colPersonalInfo"),
     CountRows(colPersonalInfo) = 0 && varEmail in 'End of Shift - Users'.Email, //second if argument
     ClearCollect(
     colPersonalInfo,
     {
     Title: varPersonal.Title,
     Email:varPersonal.Email,
     Linemanageremailaddress: varPersonal.Linemanageremailaddress,
     'IMDM email address': varPersonal.IMDMemailaddress,
     TMEemailaddress: varPersonal.TMEemailaddress
     }
     );
     SaveData(
     colPersonalInfo, 
     "colPersonalInfo"
     ),
     !(varEmail in 'End of Shift - Users'.Email) && CountRows(colPersonalInfo) > 0, //third if argument
     Clear(colPersonalInfo);
     SaveData(
     colPersonalInfo, 
     "colPersonalInfo"
     )
     ); //you have extra bracket here meaning this is not fourth If
     LoadData(
     SubmissionFormCol,
     "SubmissionFormCol",
     true
     );
     If(
     CountRows(SubmissionFormCol) <> 0,
     ClearCollect(SubmissionFormColCount, SubmissionFormCol);
     ForAll(
     SubmissionFormCol,
     Collect(
     'End of Shift New Report',
     First(SubmissionFormColCount)
     )
     ); //needed another bracket here
     Remove(
     SubmissionFormColCount, 
     First(SubmissionFormColCount)
     );
     Mail.SendEmailV3( . . . . .);
     SubmitForm(Form2);
     ResetForm(Form2);
     Notify(
     "Form successfully submitted",
     Success
     )
     );
     Clear(SubmissionFormCol);
     SaveData(
     SubmissionFormCol,
     "SubmissionFormCol"
     )
    )

    Also, have you considered shorter names??

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

  • KevDaRed Profile Picture
    16 on at

    Hey sir, thanks for your help.  

    I've been looking at this over and over again but just not getting it to be resolved, it's becoming very frustrating and need to get it done by close of play today.

     

    If(
    varEmail in 'End of Shift - Users'.Email And CountRows(colPersonalInfo) > 0 And
    (
    varPersonalInfoLookUp.Title <> varPersonal.Title Or
    varPersonalInfoLookUp.Email <> varPersonal.Title.Email Or
    varPersonalInfoLookUp.Linemanageremailaddress <> varPersonal.Linemanageremailaddress Or varPersonalInfoLookUp.IMDMemailaddress <> varPersonal.IMDMemailaddress Or
    varPersonalInfoLookUp.TMEemailaddress <> varPersonal.TMEemailaddress,
    ),
    Patch(
    'End of Shift - Users',
    {Email:varEmail},
    {
    Title: varPersonal.Title,
    Email:varPersonal.Email,
    Linemanageremailaddress: varPersonal,
    IMDMemailaddress: varPersonal.IMDMemailaddress,
    TMEemailaddress: varPersonal.TMEemailaddress
    }
    );
    SaveData(colPersonalInfo, "colPersonalInfo"),
    CountRows(colPersonalInfo) = 0 && varEmail in 'End of Shift - Users'.Email,
    ClearCollect(
    colPersonalInfo,
    {
    Title: varPersonal.Title,
    Email:varPersonal.Email,
    Linemanageremailaddress: varPersonal.Linemanageremailaddress,
    'IMDM email address': varPersonal.IMDMemailaddress,
    TMEemailaddress: varPersonal.TMEemailaddress
    }
    );
    SaveData(
    colPersonalInfo,
    "colPersonalInfo"
    ),
    !(varEmail in 'End of Shift - Users'.Email) && CountRows(colPersonalInfo) > 0,
    Clear(colPersonalInfo);
    SaveData(
    colPersonalInfo,
    "colPersonalInfo"
    )
    );
    LoadData(
    SubmissionFormCol,
    "SubmissionFormCol",
    true
    );
    If(
    CountRows(SubmissionFormCol) <> 0,
    ClearCollect(SubmissionFormColCount, SubmissionFormCol);
    ForAll(
    SubmissionFormCol,
    Collect(
    'End of Shift New Report',
    First(SubmissionFormColCount)
    )
    );
    Remove(
    SubmissionFormColCount,
    First(SubmissionFormColCount)
    );

  • WarrenBelz Profile Picture
    153,117 Most Valuable Professional on at

    Hi @KevDaRed ,

    I am not sure what close of play is for you, but it is 6:45am Tuesday here. Firsty can you please consider posting parsed text in a code box as below (the </> icon above) - it makes looking at the code much easier. Your first problem is here

    If(
    varEmail in 'End of Shift - Users'.Email And CountRows(colPersonalInfo) > 0 And
    (
    varPersonalInfoLookUp.Title <> varPersonal.Title Or
    varPersonalInfoLookUp.Email <> varPersonal.Title.Email Or
    varPersonalInfoLookUp.Linemanageremailaddress <> varPersonal.Linemanageremailaddress Or varPersonalInfoLookUp.IMDMemailaddress <> varPersonal.IMDMemailaddress Or
    varPersonalInfoLookUp.TMEemailaddress <> varPersonal.TMEemailaddress,     <Comma not needed
    ),

     

    but I have also gone through what you posted below

    If(
     varEmail in 'End of Shift - Users'.Email And CountRows(colPersonalInfo) > 0 And
     (
     varPersonalInfoLookUp.Title <> varPersonal.Title Or
     varPersonalInfoLookUp.Email <> varPersonal.Title.Email Or
     varPersonalInfoLookUp.Linemanageremailaddress <> varPersonal.Linemanageremailaddress Or 
     varPersonalInfoLookUp.IMDMemailaddress <> varPersonal.IMDMemailaddress Or
     varPersonalInfoLookUp.TMEemailaddress <> varPersonal.TMEemailaddress //you had a comma at the end of this
     ),
     Patch(
     'End of Shift - Users',
     {Email:varEmail},
     {
     Title: varPersonal.Title,
     Email:varPersonal.Email,
     Linemanageremailaddress: varPersonal,
     IMDMemailaddress: varPersonal.IMDMemailaddress,
     TMEemailaddress: varPersonal.TMEemailaddress
     }
     );
     SaveData(
     colPersonalInfo, 
     "colPersonalInfo"
     ),
     CountRows(colPersonalInfo) = 0 && varEmail in 'End of Shift - Users'.Email,
     ClearCollect(
     colPersonalInfo,
     {
     Title: varPersonal.Title,
     Email:varPersonal.Email,
     Linemanageremailaddress: varPersonal.Linemanageremailaddress,
     'IMDM email address': varPersonal.IMDMemailaddress,
     TMEemailaddress: varPersonal.TMEemailaddress
     }
     );
     SaveData(
     colPersonalInfo,
     "colPersonalInfo"
     ),
     !(varEmail in 'End of Shift - Users'.Email) && CountRows(colPersonalInfo) > 0,
     Clear(colPersonalInfo);
     SaveData(
     colPersonalInfo,
     "colPersonalInfo"
     )
    );
    LoadData( //this is not part of the top statement
     SubmissionFormCol,
     "SubmissionFormCol",
     true
    );
    If(
     CountRows(SubmissionFormCol) > 0,
     ClearCollect(SubmissionFormColCount, SubmissionFormCol);
     ForAll(
     SubmissionFormCol,
     Collect(
     'End of Shift New Report',
     First(SubmissionFormColCount)
     )
     );
     Remove(
     SubmissionFormColCount,
     First(SubmissionFormColCount)
     ); //need another bracket here maybe

    You will find parsing code as above generally lets you find syntax error much easier.

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

  • WarrenBelz Profile Picture
    153,117 Most Valuable Professional on at

    Hi @KevDaRed ,

    Just checking if you got the result you were looking for on this thread. Happy to help further if not.

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 765 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 272

Last 30 days Overall leaderboard