Policy Automation for B2C Service

Get Involved. Join the Conversation.

Comments

  • Annie Fisher

    No worries about that, at least I know now.

    So to style the container we can still use jQuery as I mentioned in my above method, it is just not the best practice as we should be using extensions to do styling where possible.  On the other hand it is unlikely to break in a future release as this code extends the OPA default behaviour.

     

  • Davin Fifield

    OK. My mistake, you are correct that you can't custom style a container without taking complete control of rendering everything inside the container, too.

    The reason for this is that the risk of such custom styling accidentally (or deliberately) changing the way the contained controls are laid out/padded etc.. Such changes would be very likely to break on upgrade, particularly if we add new features. 

    Sorry for the wild goose chase.

    Davin.

  • Steven Robert

    Hi Annie and Davin

    Thanks very much for this investigation - I have has the same experience as Annie in attempting to invoke styling for a container.

    Looking at a rendered interview there appear to be multiple nested divs (that have different names in Service Cloud interview widget).

    I have had a couple of requirements to render sections of screens - can separate through headings or <hr>, but a boundary around a section of inputs/labels would be preferred.

  • Annie Fisher

    Hi Davin,

    I don't think this actually works as 'control' doesn't appear to be a valid selector for container controls (although the documentation says otherwise - see under "Extensions used for restyling controls" section, there is a key for "control" available ).  I could be wrong though (likely!) and just using it wrong.  Take a look at the attached project, I am trying the same method with both a custom container and a label control.  The styling for the label control works fine but the custom container styling does not.

     

    Interestingly enough the Product Recommendation sample project uses a custom stylesheet to override existing OPA styles (with hard coded style names too) for the Suitable Products table, instead of using extensions.  Perhaps for some controls this is the only way to do it without a 3rd party library?

     

  • Davin Fifield

    Annie,

     

    It should be something like this, where Mytype is the custom property name you put on the container when authoring the interview, and Propval is some value you have given it.

    Put whatever styling you want in there.

    (You could also just check for the existence of the property, if that's all you need)

    I haven't actually tried this, but it should work!

    OraclePolicyAutomation.AddExtension({
        style: {
            function(control) {
                if (control.getProperty("Mytype") === "Propval") {
                    return {
                        style: {
                            color: "red"
                        }
                    }
                }
            }
        }
    });
    
  • Annie Fisher

    Hi Davin,

    Could you provide a working example of your explanation as I'd be really interested to see how that's implemented.  I can't quite picture how to do that that and I'd love to learn!

    I think I am correct in saying if you use an interview extension to hook into customContainer then you can certainly apply a style, however you are also responsible for anything else to do with that control like validation etc.  For this reason I've preferred to use jQuery in the past so as not to interfere with OPA's default behaviour.

    Cheers,

    Annie

  • Davin Fifield

    Steven,

    Write a styling extension that checks for a particular custom property name, apply the custom property with that name to the container control while authoring your interview screen, and you’ll be able to find that property using getProperty() in an interview extension at runtime. Then you can use the presence of that property to choose when to apply your custom styling to the container.

    (I think the confusion stems from the fact that getControlType() does not include “container” as one of its return values. This doesn’t mean you can’t use a custom styling extension on (non-entity) container controls, since getControlType() only applies to input type controls. )

    Davin.

     

  • Annie Fisher

    I personally try to avoid hard coding any references to the default OPA styles because as you pointed out that's a non standard method (and they could change in a future release).

    As there is no styling hook according to the documentation I think there's another way to approach this.  Are you using jQuery in your project? You could add a hidden label as the first child of the container, give it an inline class or ID and then use jQuery to get the parent and style as appropriate:

    $( ".myHiddenLabel" )
        .parent()
            .addClass( "containerStyles" );
  • Matt Sevin

    The following may work if you this is how the image is selected from the XML:

    <fo:instream-foreign-object content-type="image/jpg" height="3 in" width="4 in">
    <xsl:value-of select="IMAGE_ELEMENT"/>
    </fo:instream-foreign-object>
    

    Specify in pixels as follows:

    <fo:instream-foreign-object content-type="image/jpg" height="300 px" width="4 px">
    ...
    

    Otherwise, best to check with the BI publisher experts ...

  • Chris Flemming

    Hi Scott, I think I need to see this in action to properly understand the issue. Are you able to share the details of an OPA Hub site and associated Service Cloud site that I can use to reproduce the problem? Via email is fine.

    Thanks,
    Chris

  • Scott Heidenreich

    Thank you for your reply, Chris.  The circumstance is selecting "Yes" after a submit button is clicked.  Then syncing, then returning to the interview on the device.  During sync, the incident last updated date/time is being retrieved mapped in from the incident after submit.  I'm using this to determine if the user has synced the model, and if so, trying to hide the screen with the submit button.  This is necesary, because if the user opens the interview and clicks the submit button again, it puts the model into the upload queue again, even though it was already synced and the mobile assessment marked as completed in OSvC.  Then the next time the user syncs, an error is thrown, resulting in the cryptic error occurred contact hub administrator.  But there isn't anything that an administrator can do, other than set the mobile assessment that was completed, to cancelled. This seems like a bug, as the user shouldn't be able to put a model that was already synced back into the upload queue.

    So to prevent this from happening, I'm checking to see if the incident last updated time has been retrieved from the incident, as I only allow the interview to do that after a sync back up to OSvC, and if the attribute has a value, then hiding the screen with the submit button on it, and showing a copy of the screen without the submit button, but with a message that the interview was already synced.

    However, after sync occurs, if the user again opens the interview, the screen with the submit button is still visible on the screen, as it was the last screen the user was on, rather than the screen without the submit button.  If however, the user clicks a back button from the screen with the submit button on it, then clicks next, the screens will switch off and on as intended.

    It would be very nice to be able to show the submit button conditionally.  It also seems that once an interview has been synced back to OSvC, the submit button should have no effect - the interview should remain completed.

    I also don't know how to get completed interviews off of the device. Cancelling them after they have been completed is a non-starter as we need the completed status. and leaving them on the device indefinitely isn't a good idea either, as they take up storage and the list will get crazy long over time.

  • Chris Flemming

    Hi Scott,

    In the mobile application when you press the submit button you should see a prompt asking whether you want to mark the interview for upload. If you select "yes" you will be returned to the assessments list page. If you select "no" you will not advance in the interview - the assessment must be manually marked for upload on the assessments list page. After syncing the completed interview you should be able to view the final screen if you return to the assessment.

    Regarding the model not reacting to information retrieved after submit until you press a button - what information is being retrieved and what are you expecting to happen?

    Thanks,
    Chris

  • Jasmine Lee

    This is the Policy Automation forum, so reasonable to assume that Annie is referring to the Policy Automation product ;)

    This question was discussed and resolved on the main OPA OTN forum here: How to create an entity instance programmatically

    Cheers,
    Jasmine

  • Cosimo Galasso

    Which Oracle product are you referring to?

    CG

  • Matt Sevin

    The OPA Learning Subscription provides excellent training from getting started with OPA through to more advanced usage and topics.  The learning subscription is regularly updated with refreshed training content and quarterly updates on enhancements and new features.

    https://education.oracle.com/oracle-policy-automation-learning-subscription-complete-edition/ls_45147