Search Results for: Extensions

JavaScript Extensions for Oracle Policy Modeling

JavaScript Extensions for Oracle Policy Modeling

The JavaScript Extensions for Oracle Policy Modeling book is now available in all the channels that are currently supported:

Buy it from the Publisher

This option is probably the best if you are looking for the eBook. There is also a great bundle deal at the moment with the Getting Started with Oracle Policy Automation 2019 book. For more information you can find the details over on the P8 Tech website page.

Buy it from Amazon.com

The information that Amazon prints regarding availability of the title is incredibly vague and usually inaccurate. But at the moment, it is correct – it is shipping in a couple of days. This option is good for North American readers therefore. Find out more from the Amazon.com page here.

Buy it from Amazon.co.uk

Just like it’s global counterpart, the shipping information is usually wide of the mark but at the moment they have got it right, you can order the book from Amazon.co.uk and it will ship very fast. I’ve included a pretty picture of the book below, or you can click this JavaScript Extensions for Oracle Policy Modeling link. Full disclosure, this link is an affiliate link that earns us 50 cents extra on every purchase.

Buy JavaScript Extensions for Oracle Policy Modeling from the Book Depository

The most efficient and cost-effective way for the Rest of the World to acquire this and the other titles in the collection, the most important benefit of using this supplier is the fact that the book can be shipped anywhere in the world and they are remarkably efficient. Price-sensitive customers will find their shipment charges more attractive than Amazon in general. You can find out more from the Book Depository page for JavaScript Extensions for Oracle Policy Modeling.

What about the other book?

Some of you have been asking about Getting Started with Oracle Policy Modeling. Here are some answers:

  1. Yes it is being updated, worked started in the holiday season
  2. Yes it is being renamed because the product has been renamed and because the scope of the book is broader than ever
  3. Yes it will be released as soon as possible (probably end of Q1, early Q2)
  4. No it will not have broccoli on the cover. Tune in later to find out what it will be. Or submit your suggestion!

Input Extensions – Input Validation

Input Extensions – Input Validation

Following on from the recent posts about Errors and Input Extensions, this week we’re going to look at input validation and error handling. Not, you will understand, error handling in the JavaScript sense (writing try…catch and so forth) but how to handle errors that the user makes when entering data in your Input Extension.

Let’s set the scene with some simple examples. You have created an Input Extension in the form of an INPUT tag that displays an attribute for the user to enter. You intend to use the validate handler to do the work of testing the user’s data entry and flagging it to the user if they have made a mistake.

So you begin by understanding that the validation handler is ultimately a three way trigger : you can return true (in which case there is no error, and the data entered passes validation) or false (you wish to signal to the user there is an error, without an error message) or better still  a text string which means yes there is an error, and furthermore here is a text string to tell you what it is. For our little example, we will therefore be looking to handle true  and text string.

Basic Validation

var currentValue = document.getElementById("xInput").value;
var bBanana = document.getElementById("xInput").value === 'BANANA';

In the above example, we retrieve the current value of the INPUT and compare it to the text string “BANANA”. If you have entered “BANANA” then you have passed our validation (true) and if not (false).

if(!bBanana) 
{
return "JavaScript Validation Error";
}

Great. The case is solved, to paraphrase a famous detective. But then, one day, your Input Extension stops working. It mysteriously refuses to validate your user’s data entry, even when the data entry is correct. It simply refuses to let the user go forward, but there is no error message. So where is the problem coming from?

You take a look at the attribute you are supposed to be validating and notice that the rule designer has added something since you last looked:

Input Validation 1

So the rule designer has added a Regular Expression to the attribute. And what you are entering, perhaps, is not matching the RegEx. But how on earth are you supposed to check for that / handle that in an Input Extension? There is no documented process / property set for this, but if you dig down deep enough, you can find the following properties:

Input Validation – RegEx

control._source.config.inputRestriction.regularExpression (the RegEx)

control._source.config.inputRestriction.rawErrorMessage (the message)

The above properties give you access to the rule designer’s RegEx and associated error message. They do NOT, however, test the value of your input against the RegEx. So don’t forget to actually include the RegEx in your validate handler. At a simple level it might be something like this:

var regExpression = new RegExp(control._source.config.inputRestriction.regularExpression); 
var bTestInput = regExpression.test(currentValue);

Again, we will have a boolean variable which will tell us if the text entered has passed the RegEx validation or not. So now you can include this in your standard validation, to be able to present the user with reasonably decent message:

Input Validation - 3

OPA Hub Website Supporters can download an example project from the OPA Hub Shop. You’ll find the official reference online.

Input Extensions – DropDowns

Input Extensions – DropDowns

Many thanks to long-time reader and Oracle Policy Automation expert Aaron H for an interesting discussion just before the holiday season. The subject for this post is as you can tell, Input extensions that are dropdowns.

Our conversation was wide ranging but this article will focus on a couple of things

  1. How to ensure that the extension displays and handles the text and value elements of your list of values
  2. How to handle <uncertain>
  3. How to have a different label for <uncertain>

Along the way this will give us the opportunity to understand the usefulness of the Value() function in a rule. In later posts in this series we will look at other forms of Input, also beyond the basic INPUT or SELECT tag.

So let’s begin with a simple setup – the Zip Archive is available in the OPA Hub Shop by the way) – starting with just one attribute and a Value List:

The initial Value List looks like this – notice that in this case, there is no distinction between the displayed text and the actual value:

Input Extensions - DropDowns

In this simple scenario, one often sees extension code that focuses on the control.getOptions() method and then iterating through the various options from the returned object, something a little like this (for educational purposes only) :

var myChoices = control.getOptions();
for (key in myChoices) {
if(myChoices[key].value)
{
$('#xDropDown').append('<option value="' + myChoices[key]..text.toString() + '">' + myChoices[key].text.toString() + '</option>');
}
}

The code works fine, but makes a few assumptions that can come back and bite later when the rule designer has made changes.

  1. It does not take into account the possible change in the Value List to include display and values.
  2. It will error out if the dropdown becomes non-mandatory since “uncertain” will cause .toString() to fail

So when the developer of the rule changes the Value List to something like this:

Input Extensions - DropDowns 2

The code would no longer be useful since the [key].text and [key].value are two different values. And if we are updating the underlying control, we need to remember that we call control.setValue() so it is expecting a value, not the display value.

So maybe the code gets changed to :

 $('#xDropDown').append('<option value="' + myChoices[key].value + '">' + myChoices[key].text.toString() + '</option>');

Or something similar. All is well and the dropdown is correctly handling things :

Until the attribute is defined as non-mandatory in the Screen where it is displayed. At which point the code breaks again, as the uncertain value is not handled. Let’s take a step back and remind ourselves of the defaut behaviour in these situations, without an extension:

The standard control renders an empty option for the uncertain value. I’ve always considered it a bit of a bug that it does not respect the optional Display Value (in my case, “Not Sure” – see the screenshot a little further up) but always renders a blank, at least in all my browsers.

So in the case of an Input Extension that needs to render the uncertain value (because the control is not mandatory) and also wants to show the Display Value, the code will probably need to have another quick change:

Input Extensions DropDown Code Last One

Which will ensure that the dropdown is rendered with the correct text and value, if there is one. Also, the added bonus is that the display text of uncertain is rendered as we would expect:

Input Extension Showing Uncertain Vlaue

And finally, we have good use of the Value() function so that we can be sure that the correct value is stored in our Interview:

The function above, in a Word document for example, will return the value rather than the display value. So you can drop it onto the final Screen of your testing Project and compare the two to make sure you have gathered the correct one.

Hopefully that was fun and interesting, and you can practice yourself with your own project. As mentioned above the code is available in the OPA Hub Shop. The documentation is of course on the Oracle Intelligent Advisor website.

Just in time for the Holidays – JavaScript Extensions for Oracle Policy Modeling

Just in time for the Holidays – JavaScript Extensions for Oracle Policy Modeling

Oracle Policy Automation Interviews allow users – customers, citizens, employees – to work quickly and easily with the powerful natural language rules and policies defined in Oracle Policy Modeling through an interactive website that guides them with intelligent advice. Customers around the world rely on Oracle Policy Automation Interviews to help people calculate benefit entitlements, decide what university courses to take, return an unwanted item to the store, find ways to eat more healthily, and more. OPA drives literally thousands of business-critical processes. Introduced in 2017, JavaScript Extensions allow Interview designers to completely reconfigure the end-user experience, and this book, JavaScript Extensions for Oracle Policy Modeling, shows you – the OPA developer – how to enhance and streamline user experiences by adding customizations like:

  • Label Extensions
  • Input Extensions
  • Search Extensions
  • Options Extensions

All of these allow for the design and creation of modern, corporate-themed interactions that leverage standard HTML5 and JavaScript within the framework of Oracle Policy Automation.

This practical and fully up-to-date book also covers the advanced uses of JavaScript Extensions, including:

  • Entity Collect Extensions
  • Entity Container Extensions
  • Relationship Extensions
  • Button and Event Extensions

JavaScript Extensions for Oracle Policy Modeling is aimed at Interview designers, and Richard Napier explains and demonstrates the features of the JavaScript framework with 50 examples. These are available for download for study and further customization. This book, thanks to the author’s well-known informal style and business-driven approach, will enable both technical and non-technical readers to make rapid progress in their understanding of the JavaScript Framework.

Now Available – Great Bundle Deal

This book – in paperback form – is coming onstream with retailers (ignore Amazon.co.uk’s 1-2 months; it’s a default message and incorrect). If you would like to get your hands on a copy, now, the PDF is already live on the links below (and we have a GREAT bundle deal too – please see below.)

 

JavaScript Extensions for Oracle Policy Modeling

JavaScript Extensions for Oracle Policy Modeling is aimed at Interview designers, and Richard Napier explains and demonstrates the features of the JavaScript framework with 50 worked examples. These are available for download for study and further customization. This book, thanks to the author’s well-known informal style and business-driven approach, will enable both technical and non-technical readers to make rapid progress in their understanding of the JavaScript Framework.

JavaScript Extensions for Oracle Policy Modeling

JavaScript Extensions for Oracle Policy Modeling

It’s almost ready. The perfect Christmas gift (yeah, right, in bizarro-world) or New Year workout kit. The new book is due out in a few weeks, and you have the chance to win a free copy ahead of everyone else by entering our prize Survey (30 seconds) right now.

The book comes with 50 examples. You get them as Zip Files as well when you buy the book. The book covers all the different types of JavaScript Extensions that are currently available, with examples of each of them (sometimes many different examples) using easily-understandable business scenarios as the starting point, and using example projects from Oracle Policy Modeling – so you don’t need to install a Hub, or do anything special – which let’s you get started straight away.

  • Label Extensions
  • Input Extensions
  • Search Extensions
  • Options Extensions
  • Entity Collect Extensions
  • Entity Container Extensions
  • Button Extensions
  • Event Extensions
  • Navigation, Header and Footer Extensions

The OPA Hub Website Community has also stepped up and I am delighted to say that 8 examples (with credits) came from readers of this website. I am very grateful to them and encourage all of you to submit your ideas and code snippets for the next version.

Hopefully this book will appeal to non-technical people too – I wrote it in the same style as the others (Getting Started with OPA, Getting Started with OSvC) and tried to make it as accessible as possible to everyone.

Here, in avant-premiere, is the cover. And no, I’m not sure what those things are either. But they sure look exotic and tasty. I wanted a parsnip on the cover but these were available and they look good. These are important questions that you worry about late at night. The publisher’s website has been updated, watch this space for the launch date!

 

JavaScript Extensions

New JavaScript Extensions Book – Win!

New JavaScript Extensions Book – Win!

We’re pleased to say that our new Oracle Policy Automation JavaScript Extensions book is almost finished. Designed to be useful for anyone looking to understand how to extend their interviews with JavaScript Extensions. It comes with 50 worked examples and Zip Archives to download. It was written to help non-programming Oracle Policy Automation professionals understand what is possible. Professional Programmers can use the examples and extend them / adapt them according to their needs.

Win a Free Copy!

The new book is part of our program of providing useful resources and assistance to the community. Help the OPA Hub Website by filling in the survey below and enter to win a copy of the book and the free goodies we mentioned. We’re attempting to broaden our offerings to include various forms of training and assistance, and your feedback helps us a great deal. We want to serve the community in the best way possible and this is part of that process, learning about your needs.

If you enter the very short survey below and complete the last question, you will be entered into the draw – one person will be drawn at random and will win a copy of the book as soon as it is published (in the New Year 2020) and a bunch of other goodies – a baseball cap, a tee-shirt, a pen and a mug! So what are you waiting for? If for whatever reason, the embedded survey below does not work, you can also access it here.

Enter the Survey to win!

Create your own user feedback survey

Extensions : A First Style Extension

Extensions : A First Style Extension

To better understand the process of creating, testing and delivering a style extension, and how it relates to the Interview experience, let’s start with a skeleton example. You have been tasked with creating a text input for the Interview, which has a different behavior to the normal one. For this short example, you could simply create a new Project by selecting the Project tab and clicking New Project.

1. Before doing anything, check that the behavior you are looking to implement is not already configurable using the Styles dialog on the Interview tab. For example, there are a number of options on this page, that allow us to change the font, color and so on:

Style Extension - What to do

2. Click the Custom Files button

3. Notice the warning. If you are developing for a public sector organization or for an organization that needs to meet certain accessibility standards, you should review the warning and check that any extension you create meets the standard Web Content Accessibility Guidelines (WCAG) mentioned. You can find out more here: https://www.w3.org/WAI/standards-guidelines/wcag/.

4.In the screenshot above, the Project is called Style Extension. Notice that the folder is called interview-theme/resources. This folder can contain your Extension files, but it also can contain other resources for your Project, notably images (and a folder is already present with that name).

Adding a file is as simple as adding a new file to this folder. You can choose to add a new file manually, or you can use a code generator such as the one available from https://theopahub.com which can help you quickly create standard files to work on.

In this, our first example, let’s create a new Text File and rename it example.js. Even though it is concerned with styling rules, all extensions are always driven by a JavaScript file. But before you add the file, a word about the file structure.

Custom Style Extension Template

Most Extension creators like to use template files, since all extensions have a similar structure. You might use this sample styling template as a general starting point for self-study purposes. Over the following pages, you will implement several examples of Custom Styling Extensions; each time you will construct a file based on a template similar to this.

OraclePolicyAutomation.AddExtension({
style: {
objecttype: {
className: "css class name",
errorclassName: "error css class",
propertyname: "property value"
}

}
});

In the template shown above, there are four main areas that may be modified:

Object Type
The Object Type identifies the element you are trying to restyle. This could be the Interview content, the “Next” button, or a specific type of element such as a Calendar input Control.
Class Name
The style details (color, background, or indeed any Cascading Style Sheet content) are in most cases based on a standard CSS file with different classes.
Error Class Name
The style details to use when a control is in an error state (for example, a user has entered an invalid date).
Property Name
In simple cases, where only one aspect is changed, in certain controls it is possible to change the value without a separate style sheet. For example, in order to change only the background color of an element, it is not required to create a style sheet, you may reference the property directly as you will see in a moment.

In the case of this first walk-through, you will construct a Style Extension that changes the look of one or more text input areas in your Project.

Using the code below as your guide, add text to your blank example.js file.

OraclePolicyAutomation.AddExtension({
style: {
textInput: {

style: {
color: "darkblue",
backgroundColor: "lightgrey",
fontSize: "14px",
fontWeight: "bolder"
}

}
}
});

Notice the following key points:
1. The Oracle Policy Automation AddExtension object allows us to pass details of an extension to normal behaviour, to “register your extension”
2. The style key indicates that it is a styling extension, and you will change text color, background color, font size and weight properties in your extension
3. The textInput key tells Oracle Policy Automation that you wish to extend textInput styling
4. The entire code of your extension is a JavaScript object

Build a First Example Style Extension Project

In order to test your work, you will need to add some content to your Oracle Policy Automation Project. In the Data tab, create three attributes according to the example below (note there are two text attributes and one number attribute).

Style Extension - Attributes for Example

Make the following changes to the Interview tab of your Project

  1. Click New Screen on the Interview Tab
  2. Drag the New Screen so that it is the first in the vertical list
  3. Double -click the title and change it to “Customer Management”
  4. Click New Input
  5. Double-click each attribute until they are all visible on your Screen

Once these simple steps are finished, your Interview should look like the one below. Use the bullet points in the screenshot to make sure you have the same result.

Style Extension Interview

So you are ready to test your Style Extension. Start a new Debug session by clicking Debug in the top right hand corner of Oracle Policy Modeling. If you have followed the steps, you should see the following:

Style Extension - result

You are perhaps surprised at the result as to why both of the first two inputs are styled. That’s because the underlying HTML tags are the same. In a later example you will find out how to style numbers differently to text, and so on. There are many more options available to style developers.

But that’s it – you now have a functioning Style Extension. Enjoy, until next time!

Back to Basics : Extensions #2

Back to Basics : Extensions #2

Following on from the previous post, we delve more deeply into the JavaScript Extensions world.

Interview Execution in a Browser

So how does an Interview Extension work? Let’s begin with some basic information about how your Oracle Policy Automation Interview runs in your Browser. If you happened to be viewing an Interview right now, and you were to open the Console (F12 in Google Chrome, or Microsoft Edge. Check your Browser documentation for the equivalent key or menu option), you might be able to view something like the following screenshot. Check the steps under the image as you may need to refer to them in your own case.

Extensions

In this screenshot I have launched a Project using the Debugger. Remember that if you hold down F5 while clicking the Debug button, you will open the Interview in the Debugger and in your default Browser.

  1. Your web server may of course be a different address.
  2. The web-determinations folder will not have the same numeric suffix as in this screenshot, indeed will most likely not have a suffix at all. This is a feature of the Debugging session.
  3. The js file is most likely in the staticresource folder, however if you are in a more integrated environment it may be in a different subfolder, or a different folder altogether. But it will be present.
  4. The contents of the js file can be read more easily by selecting (in Google Chrome in this case) the option to pretty print the code.

Interviews.js

This file is the foundation of the Interview experience provided by Oracle Policy Automation. It contains all the code necessary to make the user experience function correctly. Inside this file, however, there is a built-in capacity to accept extensions that change the behaviour of the Interview.

In your Console, search in the file for the following text – “customLabel:” (without the quotation marks, but with the colon). You should find one instance of that text, as shown in the screenshot below.

Extensions

  1. Search for the text
  2. Find the text in the file.

Take a moment to perform a second search in the same file, for the text shown below. Use the screenshot as your guide.

  1. Ensure you are looking at interviews.js
  2. Search for this text
  3. View the style definition for textInputStyle.

Accepted Extension Types

Notice in the first example, that customLabel is only one of a series of items in the first list. These are the recognized types of Control extension that we, as Oracle Policy Automation Project workers, are permitted to develop.

In the second search you found that there was a style defined for controls called textInputs. Although not quite as obvious perhaps as the first example, an Oracle Policy Automation Project might want to override the Style(s) used in a Project, in order to comply with corporate guidelines for example: and this system will help us do just that. Style Extensions use keywords in the same way to indicate which elements you wish to style.

About Extensions

It is not important at this stage to understand how these extensions are created or used. It is, however fundamentally important to understand that you will be extending Oracle Policy Automation Interviews by adding one or more of these acceptable extensions, and that they will be run in the browser in the same way as the standard JavaScript is already. These interviews can then be better adapted to your IT environment. As an example, read how Styling Extensions enable integration visually with Oracle Content & Experience Cloud.

More on this subject, with some worked examples, shortly.

Worldwide
Logo by Southpaw Projects LLC