Welcome to the OPA Hub!


Category Archives: 19A

Business Process : Force PDF Download in OPA

Business Process : Force PDF Download in OPA

After last week’s business case put forward about Calendar Blackout dates, this week we can thank Arnaud D and Sylvie A from Switzerland for their excellent use case. This week we will be discussing the idea of letting a user progress to the end of an Interview, only if they have clicked to download a PDF file. So, can we Force PDF Download in OPA?

There is not really a technically feasible way to prove that a user actually read a PDF. But if we can force them to download it, at least we know they have gotten that far!

The business case is easily applied to many industries, for example where terms and conditions or a contract are generated and tacit approval needed before the user continues. Or, more simply, you need some way to encourage people to read the BI Publisher thing you spent all those weeks developing.

It is also a good opportunity for us to investigate the new custom Button extensions available in Oracle Policy Automation 19A. So this won’t work in 18D or earlier. The approach we are going to take will involve two different extensions. Let’s go!

Input Extension

The input extension is needed because we wish to capture the value of a Boolean attribute for our demonstration. Navigating forwards will only be allowed if this Boolean is true.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/*  Generated by the OPA Hub Website 29/03/2019 19:35
Educational Example of Custom Input Extension for Oracle Policy Automation
I will remember this is for demonstration purposes only.
 */
OraclePolicyAutomation.AddExtension({
	fullCustomInput: function (control, interview) {
		if (control.getProperty("name") == "xInput") {
			return {
				mount: function (el) {
					console.log("Starting customInput Mount");
					var div = document.createElement("input");
					div.id = "myInput";
					div.value = interview.getValue("my_flag");
div.setAttribute("style", "visibility: hidden");
el.appendChild(div);
console.log("Ending customInput Mount");
$(".opa-document").click(function(){
console.log("Clicked Link");
control.setValue(true);
});
},
update: function (el) {
console.log("Starting customInput Update");
 
console.log("Ending customInput Update");
},
validate: function (el) {
console.log("Starting customInput Validate");
 
console.log("Ending customInput Validate");
},
unmount: function (el) {
if (control.getProperty("name") == "xInput") {
console.log("Starting customInput UnMount");
 
interview.setInputValue("my_flag", $("#myInput").val());
var myInput = document.getElementById("myInput");
myInput.parentNode.removeChild(myInput);
console.log("Ending customInput UnMount");
}
}
}
}
}
})

So what’s going on here? Basically we are putting a click event on a PDF download. Notice line 17 : this adds a click event.  So as soon as the custom Input is loaded, an event is added to another control using jQuery. When the link is clicked, we update our flag to true. We use the style selector “.opa-document” to find the link. If you have more than one link, you will need a more precise method of finding it. Other than that, the custom input itself is invisible, and simply reads the current value of the flag into the control.

Button Extension

The other extension, for a nextButton, uses jQuery to display a dialog when you try and leave the screen before clicking on the link (the flag is false). Otherwise it lets you navigate without issues.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
OraclePolicyAutomation.AddExtension({
	customNextButton: function (interview) {
		let button,
		caption;
 
		return {
			mount: function (el) {
				const screen = interview.currentScreen();
 
				button = document.createElement("div");
				button.setAttribute("title", "Print Your PDF First");
				button.setAttribute("class", "opa-back");
				button.setAttribute("role", "button");
				button.setAttribute("style", "	text-overflow: ellipsis; white-space: nowrap; line-height: 1; cursor: pointer; padding: 0.7em 1.2em; border: none; text-decoration: none; -webkit-appearance: none; flex: 0 0 auto; text-align: center; color: rgb(255, 255, 255); border-radius: 6px; background: rgb(20, 116, 191); font-size: 16px; font-style: normal; font-weight: normal; margin-left: 6px; visibility: visible; outline: none;");
 
				caption = document.createTextNode(screen.getNextCaption());
				button.appendChild(caption);
 
				var dialog = document.createElement("div");
				dialog.setAttribute("id", "dialog");
				dialog.setAttribute("title", "Warning");
 
				var dialogtext = "Please download your document first.";
				el.appendChild(dialog);
 
 
				button.onclick = function (evt) {
					evt.preventDefault();
					if (interview.getValue("my_flag") == true) {
						interview.submit();
					} else {
						$("#dialog").dialog();
						$("#dialog").text(dialogtext);
						console.log("Not Yet ");
						console.log("Flag Value is " + $("#myInput").val());
					}
				}
 
				el.appendChild(button);
			},
			update: function (el) {
				const screen = interview.currentScreen();
 
				caption.textContent = screen.getNextCaption();
 
				if (screen.hasNextButton())
					button.removeAttribute("disabled");
				else
					button.setAttribute("disabled", "disabled");
			},
			unmount: function (el) {}
		}
	}
});

So what’s happening? The early part of the mount is simply painting a nice button on the screen. We could of course not display the button at all, but the User Experience might be better if we display it always, just prohibit using it in certain circumstances. Starting around line 19 we create the dialog and make it ready for use.

Line 27 includes the button click routine which either displays the dialog, complete with a message, or just lets you navigate as normal.

The other lines in the unmount are just taken from the example in the online help, where if this is the last Screen, no next button is available. But our business case is based on it not being the last.

Force PDF Download : Animated GIF

In the animated GIF above, you can see what it looks like.

The Project Zip is in the shop. Have fun!

What’s New in Oracle Policy Automation 19A?

What’s New in Oracle Policy Automation 19A?

The newest release has come off the production line and this one is a real cracker, full of useful and exciting new features. Here is an overview of what’s new in Oracle Policy Automation 19A.

  • New Images in Forms

Ever wanted to upload images during an interview and have them appear in the PDF output. Well, now you can! In the Sample XML file that you have loaded into your BI Publisher Desktop instance with Microsoft Word, you should now see extra “Fields” much in the same way as Signatures are currently handled. Similarly, special tags are required to turn the Base64 encoded text back into images, but the help file gives you all you need.

  • Use attributes in Extensions, even when they are not on the Screen in question.

A huge leap forward for Extension writers. Now you can specify certain (as required) attributes that are available to your Extensions without having to add them to whatever Screen(s) you need to add extensions to. It’s simple. Create a new file called opm.extension.data.json and add it to  your resources folder. The file, as the name suggests, is a JSON file containing the list of attributes you need to use. Then you can call the new getExtensionData() method of the Interview object to get hold of the data in JSON format at runtime. Special care will be needed not to slow performance when requesting lots of child data since it will have to return the parent and children. All of the items need to have public names as usual.

  • Chat API

Using the Chat API to facilitate a single-stream trackable / auditable conversation, OPA can be integrated into Digital Assistant, Facebook Assistant, Service Cloud Chat

  • Extension Enhancements

Now we have extendable Buttons, we can also retrieve Hint Text for attributes!

  • Mobile Enhancements

Close to my own heart these ones : now we can run Mobile assessments without an Internet or Hub connection. Please welcome the Mobile Answer API!

And that’s not the end of what’s new in Oracle Policy Automation 19D, because we can now launch out of the box OPA Mobile using a custom URL schema. To put it simply, you can start the OPA Mobile App from a URL in your browser, or from another App, and fire up the Interview you need. Awesome!

  • Hub Enhancements

Now you can check to see if a Project is using the correct Inclusions versions using a CSV report available in the Hub.What's New in Oracle Policy Automation 19A

This feature is also available in the Oracle Policy Modeling application, in the Inclusions pane of the Project tab.

You have also access to the new CheckPoint Inspection API, to take a look at the (potentially stale) data in CheckPoints and analyse it. Great news for GDPR-minded people.

  • Checkpoint Enhancements

We welcome better handling of resumed Interviews that fail to resume because of inaccessible data since the Checkpoint was saved. Starting with 19A, as much as possible of the data will be loaded into the Interview when it is resumed. The behaviour can be enabled on upgraded older projects from the Interview tab. Oracle Service Cloud users get a bonus of being able to choose to restart or load checkpointed data when resuming.

Summary

What’s New in Oracle Policy Automation 19A?

Told you this was a big one! Thanks as always to the Oracle Policy Automation Product Development team. Awesome work!