Using Page Parameter as Data Grid XPath Constraint

0
Hello all, I am trying to make a data grid display hours recorded by a certain employee, on a certain day, for the projects which they are active in, and allow the employee to edit those hours.  Essentially the goal is that: -Any existing entries for the user on the given day of the week are displayed, as well as entries with a quantity of 0 hours for any projects which they will be putting in hours for but which have not yet had hours on that day -The user inputs hours one day at a time by editing the quantities in the “Hours” column, and can easily switch between the days of the week.  There are a few entities involved:  -Resource (employee, with key attributes of ID and Name) -Project (ID and Name are all that matter here) -ProjectHours (associative entity between Resource and Project; also contains quantity of hours and a date which the hours were recorded on) -ProjectRole (another associative entity between Resource and Project, which defines a Resource’s role on a project – before anyone asks, you can record hours for a project without having a role, and you can have a role without recording any hours, so the ProjectHours entity should not be related to this, it is just a formal tracker which provides suggestions for where users should enter hours and helps predict the allocation of employees’ time) -UserEntry (associative entity between Resource and Week) -Week (since users will select one particular week to input hours for, e.g. week of August 10th, this entity stores the information on what the date of that week’s Monday, Tuesday, Wednesday, etc. would be – I am a beginner who is not great with dates and the time horizon of this app is short, so we are pre-defining the weeks which will be relevant in the app for the user to choose from) The user first enters their name and selects the week on a form. This is the “UserEntry” object, it is a non-persistent entity which is passed to the page to provide the context of which week and which resource to pull hours entries for. Additional forms can be accessed from the page so this entity is passed around to make sure the user’s original entry of week and resource are maintained.  On the page there will be 7 tabs (one for each day of the week) in which the users will see their project hours in a data grid and edit as needed.  Currently, I’m retrieving these via a microflow (each tab is correlated with a given day, so we can select any hours which have a date equal to the Weekday of that tab + week with the entered resource ID), and this microflow can access the page parameter of the UserEntry’s week + resource.  However, the microflow of course makes it so that the quantities can’t be edited.  I’d like to instead write an XPath constraint that still retrieves hours, constrained by the resource ID being that of the UserEntry and the date again being tied to the selected week + the tab the user is on. However, I am having trouble accessing the page parameter of the UserEntry in the data grid’s XPath constraint.  Currently I am using the following constraints: [HoursDate = $UserEntry/MyFirstModule.UserEntry_Week/MyFirstModule.Week/SundayDate] [ResourceID = $UserEntry/MyFirstModule.UserEntry_Resource/MyFirstModule.Resource/ResourceID] What am I doing wrong? Is there a different way I should be pursuing this goal? Thanks for your help.
asked
1 answers
4

Hi, it’s me again.

Through some troubleshooting I’ve solved my own problem! I’ll answer it for posterity in case other noobs come along.

There is a fantastic implementation in XPath syntax of ‘[%CurrentObject%]’ – this checks against the page parameter of the current data view that a data grid is contained in. As long as you define the association when creating the objects, you can make an XPath constraint that references the parameter as ‘[%CurrentObject%]’. Also, there’s a function specific to XPath syntax to restrict dates. Awesome!

My new constraints are: 

[MyFirstModule.ProjectHours_UserEntry = '[%CurrentObject%]']
[weekday-from-dateTime(HoursDate) = 1] (this sets to Sunday – 2 would be Monday, 3 Tuesday, etc.)

and the data grid displays ProjectHours. There is also the page parameter of the UserEntry from the previous form.

Best of luck all!

answered