3 Replies Latest reply on Jun 18, 2019 9:37 AM by RichardNapier

    Loading and selecting dynamic instances of an object to edit

    Aaron Houston - Houston Technologies LLC



      I have a few projects that'd like to be able to select multiple dynamically loaded instances of an object (think loading all contacts based on some filter conditions) and associate them to a new object.


      A simple way to express this is by the following example:


      Let's say I am a manager of a company and need to perform an HR function.


      I'd like to submit a ticket to transfer potentially multiple of my employees (the employees I am a manager of) to a new organization within my company.



      Can anyone think of an aesthetically pleasing, and efficient way to get this done?


      I've already implemented a version of this, but was thinking of revisiting to optimize.


      Currently, I've set filter attributes to be collected on one screen throughout the interview where it makes sense, and load the associated "contacts" to be selected on another screen. This then correlates to an inferred entity that allows me to update the instances that I've selected. The inferred entity is wrapped in a rule loop, because the number of instances selected can change, and I have to ensure I've captured each instance.


      A previous version of my implementation was essentially dynamically loading each "contact" one at a time by making the "manager" enter a unique identifier first, then displaying each loaded contact on the following screen. It seemed a bit clunky to me so I revised the approach.


      I was thinking of extending OPA via javascript to allow the "manager" to do a text search against the contacts table in OSvC via an API call and the text search JS extension example. This would then add the instance of the contact to the entity in OPA.


      Any thoughts on an a better way to get this task done?



      Aaron Houston


      P.S. Is there a reason some of the "to-one" relationships aren't exposed within OPA to map to? E.g., the person's organization? It states in documentation this isn't supported. Is this going to be supported in the future, or any justification as to why this isn't currently supported?

        • 1. Re: Loading and selecting dynamic instances of an object to edit

          Hello Aaron


          I had to do something similar using another CRM, and opted for a query for all workers whose parent worker Id was that of the manager (this was with Siebel, so it was Parent Position Id).


          I appreciate that the manager might not be the direct manager of the worker in your case, but perhaps a ROQL query would work.


          Screen 1: Select Criteria for the query and make the REST call before the Screen unloads. Load the result into a global variable.

          Screen 2 : Show a custom Entity Collect with the result in a Custom Entity Collect (each row of the json response becomes a row on the Control) on mount. The user can (de)select the rows they want using a button per row (or  checkbox with an EventListener) to store the value of the checkbox. You could control.removeRow(n) the offending selected rows for example.

          Screen 3: You can now do with it as you wish (pass it back as an entity to OSvC, or whatever).


          There's a simple example loading Excel data, transforming it to JSON, and entering it into an Entity Collect here https://theopahub.com/main/importing-data-into-an-interview-excel-example/ that might perhaps explain more clearly.

          1 person found this helpful
          • 2. Re: Loading and selecting dynamic instances of an object to edit
            Aaron Houston - Houston Technologies LLC



            Thanks for your reply!


            I was considering the REST call route, as previously mentioned. I may continue that route given your confirmation.


            Have you implemented a version of this before?


            I wonder if combining the text search JS extension with the REST call that filters manager's employees for dynamic lookup would be the simplest version of a solution here.


            Do you have any thoughts?



            Aaron Houston


            P.S. The articles you wrote regarding excel loading and conversion to entity instances is fantastic! Thanks for linking the post here.

            • 3. Re: Loading and selecting dynamic instances of an object to edit

              HI Aaron


              The custom Search Extension REST call will return a nice JSON object and the commit mechanism is built around the user selecting one item from the list (so, I suppose, one employee).


              I think I get what you are aiming for now - the advantage of the Search extension is that the manager can make lots of "searches" to return records, and select them each time. I suppose you could easily add each selected item to an array or an object before displaying / working with them on the next page.


              What we did with Siebel (but sadly don't have access to it any more) was slightly different - we split it into several screens. The first, we gave the user a bunch of check-boxes and text boxes so they could build their "query". Then the REST call (not connected to a Search Extension, just an ajax call) was made via a Custom Label (which was actually a button marked "Search"). The data was retrieved into a JSON object.


              Then the user had to click Next to see the results, displayed in a list - an Entity Collect - before they "submitted" the interview and we sent the selected people back to Siebel for processing by a Workflow.


              We could get away with this because it was reasonably close to the "Click Query, make criteria, click Execute Query to see the results" paradigm of Siebel.


              I'll take a look at the scenario you are suggesting and try and build out a demo - not with Service Cloud but with some other data source - it's actually the flow that I'm interested in

              1 person found this helpful