Skip to Main Content

Intelligent Advisor

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Existing entity instance showing in the interview

Anju NairJun 8 2022

Hi

I have a custom object in Service Cloud. It is the child of incident object. We can create multiple records of this child object for incident. In OPA screens I have, when I add all instances of entity, when I run the interview I am seeing the existing instances as well. I just need to create a new entity record and do not want to see any existing records. Is it possible to hide existing entity instances.

Thanks
Anju Nair
.

Comments

Ian G Clough

There are a couple of possible approaches:
Map in your original entity from the custom object and create another entity which you collect as your new entities. From these two entity sets infer a third entity which is the one you will map out to your custom object. A little tricky in the rules but should be possible.
A possibly easier alternative is to add a customisation, setting the 'display' attribute on pre-existing rows to ''none'. You should be able to style the row element as per table 5 in the referenced document.
https://documentation.custhelp.com/euf/assets/devdocs/cloud22a/IntelligentAdvisor/en/Content/Guides/Developer_Guide/Web_Interviews/Styles_and_scripts/Extensions_for_restyling_controls.htm

Richard Napier

Hi All
[Ian G Clough](/ords/forums/user/Ian G Clough)'s excellent response reminded me that I actually have his customization suggestion in our JavaScript archives:
For example, load incidents for a Contact and you want to hide existing incidents and let the user create new ones, this is how it might go in detail

  1. In the interview, set up an entity collect and add a custom property so we can target our extension code at the collect.
    image.png2) Add a JavaScript extension file to the project via Interview - Styles - Custom Files and drop it into the interview-themes folder. It might look like this:
OraclePolicyAutomation.AddExtension({
    style: function(interview) {
        return {
            tabularContainer: function(control) {
                if (control.getProperty("demo") == "highlightrow") {
                    return {
                        "row": {
                            className: function(context) {
                                return interview.getValue("incident_id", context.entity, context.instance) > 0  ? "HideClass" : "DontHideClass"
                            }
                        }
                    }
                }
            }
        }
    }
});

The code executes on the entity collect with the property, and sets up a CSS class to be chosen on each row.
Then add a CSS file to match the two classes:

.HideClass {
	 background-color: rgb(255, 0, 0)!important;
}
.DontHideClass {
	background-color: rgb(255, 255, 0)!important;
}

The classes are not supposed to be a final result but a demonstration (hence the !important; to force the background colour which is not always appropriate in real life).
Obviously you can see in this demo, that we don't hide the rows - we colour it red (for existing rows) and yellow (for new rows) to demonstrate the principle. If you want to hide something then it's going to be "display : none" or similar that you use in your HideClass.
You can see that we check an attribute called "incident_id" which is of type number (it's the numeric record id from Oracle B2C Service Cloud in this case) . This is one of the attributes mapped in to the entity in OIA. Any row that is already existing in the database has a numeric value in this attribute. New rows will not have any value. So this is the demo "rule" that will highlight existing rows in red, and new rows in yellow.
My code is a demonstration, so there is no checking of the data type or value, we just assume that if it is greater than 0, that will do. Of course in real life you will need a more professional approach.
When we load the Screen and display the rows, you can see existing rows are red, and a new row (that I just created) is yellow:
image.pngI have attached the Zip file that contains this demo code. You will need to map the relevant entity using your own connection, and ensure that the incident id has a name of "incident_id" to make this work.
Sorry for jumping into the thread, but [Ian G Clough](/ords/forums/user/Ian G Clough) 's remark triggered a memory so I thought I would share it.
Cheers
Richard
HideShowRows.zip (23.36 KB)

Anju Nair

Thank you so much Ian and Richard. This solution worked.

I have another question on this. I am trying to get the ID of the instance I created during the interview. But not getting it. Can you please help on this. I am able to get all the IDs of the existing instances but not the one I newly created.

Thanks
Anju Nair

Richard Napier

Hi
I can think of one, perhaps two ways to do that.
The first option is using ExecuteQuery

  1. Since the ID is provided by the CX, you would need to submit the records at some point, obviously. Once you have submitted them, you could perform an ExecuteQuery to return the records. Since the ExecuteQuery uses an unrelated mapping, you could provide a filter to ensure you only returned the new records (created by, created date, source, that sort of thing). So you add the record on Screen A:
    image.png2) On a later Screen B you display the results of an ExecuteQuery on the CX incident object. This should return the record(s) matching the criteria you set, and you map in the ID to see it:
    image.pngIt might be possible to load the incident "after submit" but that will probably require a specific mapping to Global to work so I don't think that will suit you.
    Online documentation for ExecuteQuery.
Anju Nair

Thanks for this valuable information Richard.
We have PDF generated using BI Publisher in this project. We are facing issues there as well due to this multiple child object instances. Is there any way we can pull only the new instance data in the PDF.

Thanks
Anju Nair

Richard Napier

Hi.
good question - I am not sure if these new id attribute values would be available to BI Publisher even after a submit.
@fiona-guy-oracle responded to a previous related question about obtaining the id of newly created instances with BI publisher here, I am not aware if anything has changed but perhaps she can clarify if the new ids would be visible after an ExecuteQuery.
See her comment here :
https://community.oracle.com/tech/apps-infra/discussion/4480461/include-incident-reference-on-submitted-attachments#latest
See my response below, following my testing it would appear that the new ID is not available. But hopefully if you read the next post, the proposed solution would work for you.

R

Ian G Clough

If you don't actually need the ID field in the document but simply want to eliminate existing instances then you could just check for the presence of the ID field in your document template.

Richard Napier

Hi Anju
Well, I did some more testing and probably have the answer. You will need to split the interview into 2 parts and join them together with a redirect.
The ExecuteQuery technique I described above, I could use it working with Oracle Siebel as the backend CX, but it didn't work in Oracle B2C Service Cloud. The Oracle B2C Service Cloud didn't return the record created in the previous Screen when I called ExecuteQuery. I adjusted the ExecuteQuery condition to be sure to see the record, but no luck. I can only assume that there is some sort of session-based cache or visibility effect going on there.
The record shows up correctly when you start another interview session, so once you open another interview, the record is retrieved successfully.
This means that my suggestion will not work for Oracle B2C Service Cloud. In Siebel I have complete control over the ExecuteQuery and the database which is of course different to Oracle B2C Service Cloud.
So, to give you a modified solution - submit the new records in the end of an interview with a Submit button then redirect to the second part of the interview.
Configure a button to Redirect (or Submit and Redirect, depending on your interview Screens) the first interview to a second interview which loads the data again, and it should load the new records: I tested this and it seemed to produce the desired effect:
Interview 1 : Load existing and create new. Note highest existing ID number ends in 638.
ThirdFrame.pngPerform ExecuteQuery. Note that the just added record (probably 705639) is not present in the Screen:
ExecuteQuery1.pngThe new record is not visible in PDF output either:
PDF1.pngNow, in the first interview, use a redirect to go to a second interview
Redirect1.pngThe new interview instance starts. The ExecuteQuery or Load, depending on your Screen structure) loads the data and it includes the recently created record.
ExecuteQuery.pngAnd a PDF generated of course has it as well.
PDF2.pngSo I reckon that is a nice simple way to meet both requirements to retrieve the IDs and put them into a Form.
Apologies for the extra time spent looking into ExecuteQuery, it's behaviour depends on the application and I was using Oracle Siebel for some prototyping as well as Oracle B2C Service.
Notes:

  1. The PDF file was built using a standard loop for entity level attributes https://documentation.custhelp.com/euf/assets/devdocs/unversioned/IntelligentAdvisor/en/Content/Guides/Policy_Modeling_User_Guide/Forms/Analytics_Publisher_code_for_OPM.htm
  2. The ExecuteQuery condition might be a challenge to be completely reliable since B2C Service has only CreatedTime (which is a date and time) available, and the functions for ExecuteQuery are quite limited https://documentation.custhelp.com/euf/assets/devdocs/unversioned/IntelligentAdvisor/en/Content/Guides/Policy_Modeling_User_Guide/Data_mapping/Define_conditions_for_loading_data_during_interview.htm
    If this proposed solution is not available to you for whatever reason, then you will have to consider other options. Other potential ideas (customization, so to be considered only when you run out of other options and after a risk analysis) if you absolutely must generate a PDF with the new ID(s) in them include the following :
    Using the REST API to insert new data into B2C Service and using alternative PDF generation techniques of which there are a few. Some ideas are here :
    PDF generation part one https://intelligent-advisor.com/main/intelligent-advisor-forms-bi-publisher-anvil-easel-ly/
    PDF generation part two https://intelligent-advisor.com/main/intelligent-advisor-forms-bi-publisher-easel_ly/
    REST API to work with B2C in OIA interview.fetch() https://intelligent-advisor.com/main/interview-fetch-oracle-b2c-service-cloud-rest-api/
    be aware that all of these are using JavaScript extensions to access entity instance data and represent customisation and therefore may not be appropriate for your scenario.
    R
Anju Nair

Hi Richard,

Thank you so much for explaining the solution in detail.
We tried splitting the existing interview in to two parts and redirecting to the second one using Submit and Redirect. We are configuring the interview for Call center agents. So when we redirect to the second interview using the interview URL, we are getting the below error:
"This interview can only be used by logged in agents in B2C service agent interfaces"
We tried making it anonymous, but in case of anonymous, we do not have an option to Load the data.
Can you please help us to figure this out.
Can't we redirect using interview URL, in case of call center agents.

Thanks and Regards
Anju Nair

Richard Napier

Hi
Both the first and second part will need to be called through customer portal pages
For example, part one is

https://xxxxx.custhelp.com/app/partone.php

The page is set to login_required="true" (if that is required) and contains the OPA widget pointing to the first part of the interview.
At the end of the first part, you submit and redirect. You set the new record id to be "load after submit" to be able to recover it.
You redirect to part two with something like this (assuming %recordid% is the name you gave to the attribute you "load after submit" which is the id of the newly created incident.

https://xxxxx.custhelp.com/app/parttwo/i_id/%recordid%

You can then load the new incident record into part two, and continue.
Regards

1 - 10

Post Details

Added on Jun 8 2022
10 comments
282 views