Hi team,
I hope you are all well. I have a question regarding the mechanisms behind repeated grid which we are trying to use to populate dynamic information: <http://discuss.orbeon.com/file/t375805/repeated_grid.png> In the screenshot above, we managed to pre-populate the entire row by first passing the Item ID from URL parameter, and then the Item ID will act as a trigger to retrieve the rest of the row from sql database via database service. The issue we are facing right now is in our use case we will always need to pre-populate different numbers of rows everyday for different Item IDs, however we are not sure if repeated grid has the ability to display all rows accordingly based on the number of Item IDs in the URL upon initial form load. e.g. at the end of URL we have ItemID1=339946&ItemID2=339947&ItemID3=339948, we want the form to display all three rows already right after opening the form. Please let me know if repeated grid has the ability to handle this scenario, if not please could you suggest some other approaches? One way we can think of is to create a certain number of normal grid with same set of controls as place holders, but it is tedious to create and will result in issue when having more Item IDs than place holders. Thanks and I'm looking forward to your reply. Kind regards, -- Sent from: http://discuss.orbeon.com/ -- You received this message because you are subscribed to the Google Groups "Orbeon Forms" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To view this discussion on the web visit https://groups.google.com/d/msgid/orbeon/1592286370297-0.post%40n4.nabble.com. |
Administrator
|
Hi Adam,
You are saying that you would like to iterate over the `ItemID` passed as request parameters, and for each one run the database service with the current `ItemID`, create a new row in the grid, and populate it from what the service returned. I think you should be able to do this with the action syntax: https://doc.orbeon.com/form-builder/advanced/services-and-actions/actions-syntax Also, instead of `ItemID1=339946&ItemID2=339947&ItemID3=339948`, I would use `ItemID=339946&ItemID=339947&ItemID=339948`, that is using the same parameter name for all ids, so you can use a single call to `xxf:get-request-parameter('ItemID')` which will return a sequence of ids, on which you can iterate. https://doc.orbeon.com/xforms/xpath/extension-functions/extension-http#xxf-get-request-parameter You'll let me know how it works out! ‑Alex ----- -- Follow Orbeon on Twitter: @orbeon Follow me on Twitter: @avernet -- Sent from: http://discuss.orbeon.com/ -- You received this message because you are subscribed to the Google Groups "Orbeon Forms" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To view this discussion on the web visit https://groups.google.com/d/msgid/orbeon/1592328325480-0.post%40n4.nabble.com.
--
Follow Orbeon on Twitter: @orbeon Follow me on Twitter: @avernet |
Hi Alessandro,
Thanks for your reply. Yes this is exactly what I wanted to achieve and your explanation makes sense. However, is having an http service set up one of the prerequisites for this approach? Currently we have `xxf:get-request-parameter('ItemID')` configured in calculated value of the field and used the value to trigger database service. How do we make a single call of this function to get all ItemIDs? I tried to add the function to the control in source code but I couldn't get it to work, maybe I'm doing it wrong. Please could you point me to the correct direction? <http://discuss.orbeon.com/file/t375805/ItemID.png> Thanks in advance! -- Sent from: http://discuss.orbeon.com/ -- You received this message because you are subscribed to the Google Groups "Orbeon Forms" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To view this discussion on the web visit https://groups.google.com/d/msgid/orbeon/1592366538062-0.post%40n4.nabble.com. |
Hi Alessandro,
I merged the function `xxf:get-request-parameter('ItemID')` into the database service that we used to retrieve data from sql, and I think this should store a list of IDs from query (in this case only 339946 and 339947) <http://discuss.orbeon.com/file/t375805/ItemID_DBservice.png> However, when I put both ItemIDs in the URL, the repeat grid shows duplicates of only the first ID: <http://discuss.orbeon.com/file/t375805/repeat_grid.png> I am not sure if I am on the right track, please kindly explain how we can rectify this. I appreciate any help and suggestions. Thanks! -- Sent from: http://discuss.orbeon.com/ -- You received this message because you are subscribed to the Google Groups "Orbeon Forms" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To view this discussion on the web visit https://groups.google.com/d/msgid/orbeon/1592372377787-0.post%40n4.nabble.com. |
Administrator
|
Hi Adam,
Based on your the screenshots, it looks like you are trying to use the Actions and Database Services, found under the Advanced tab. But if you'd like to call a service, iterate on the result, and for each iteration make a database request, and based on the result populate a grid row, then you will instead need to use the Action syntax (see you again the relevant link below). This means that you won't be able to use a UI, but instead will need to do this writing code that you add to the form (this at least until Form Builder implements a UI for this). Does this make sense? https://doc.orbeon.com/form-builder/advanced/services-and-actions/actions-syntax ‑Alex ----- -- Follow Orbeon on Twitter: @orbeon Follow me on Twitter: @avernet -- Sent from: http://discuss.orbeon.com/ -- You received this message because you are subscribed to the Google Groups "Orbeon Forms" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To view this discussion on the web visit https://groups.google.com/d/msgid/orbeon/1592613637008-0.post%40n4.nabble.com.
--
Follow Orbeon on Twitter: @orbeon Follow me on Twitter: @avernet |
Hi Alessandro,
Thanks for your reply and explanation, it makes sense and has worked well. I appreciate your help. In some of our other use cases, we would like to prepopulate data via REST API. Here I have created an http service, returning data in JSON format: <http://discuss.orbeon.com/file/t375805/JSON_output.png> When testing the http service, it positively returned the output: <http://discuss.orbeon.com/file/t375805/http_test_result.png> However, when creating an action upon the service, I kept getting the error message 'Unable to complete action'. I suspect that I might have configured the action wrong as I am not very sure what I should put in xPath in 'Service Request Actions' and 'Service Response Action' when the data returned is in JSON format: <http://discuss.orbeon.com/file/t375805/action_config_1.png> <http://discuss.orbeon.com/file/t375805/action_config_2.png> Any help will be much appreciated. Kind regards, -- Sent from: http://discuss.orbeon.com/ -- You received this message because you are subscribed to the Google Groups "Orbeon Forms" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To view this discussion on the web visit https://groups.google.com/d/msgid/orbeon/1594123705610-0.post%40n4.nabble.com. |
Administrator
|
Hi Adam,
I am not seeing anything wrong in the screenshots you attached, but the "Unable to complete action" message makes me think that an exception might have happened on the server. Could you check if you see an exception go by in the `orbeon.log` when you perform that action? ‑Alex ----- -- Follow Orbeon on Twitter: @orbeon Follow me on Twitter: @avernet -- Sent from: http://discuss.orbeon.com/ -- You received this message because you are subscribed to the Google Groups "Orbeon Forms" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To view this discussion on the web visit https://groups.google.com/d/msgid/orbeon/1594263956879-0.post%40n4.nabble.com.
--
Follow Orbeon on Twitter: @orbeon Follow me on Twitter: @avernet |
Free forum by Nabble | Edit this page |