The CreatorCon Call for Content is officially open! Get started here.

How To Create Url that Triggers a Ui page ??

Tarun2
Tera Contributor

Hi ,

 

I have a requirement to Trigger UI Page using a Button . Onclick() i am trying to open a Ui page.

* Button Created using Ui Actions in a Table's Form 

* Both Ui page and Ui action are in the Same scope .

                              I have Tried these ways :

1.g_navigation.openPopup() for ui page

2,window.open('/<UipageNAME >.do?sysparm_id='+g_form.getUniqueValue());

3.Dialog

var dialog = new GlideDialogWindow("UipageNAME");
dialog.setTitle("UI Page Opened");
dialog.setPreference("sysparm_id", g_form.getUniqueValue());
dialog.render(); 

                         Nothing Worked For me . Maybe , I had issue in Creating url for ui Page .

  

Check My Previous Thread : https://community.servicenow.com/community?id=community_question&sys_id=a0fb1736db13c0502be0a851ca96...

 

 

 

 

 

But , i had a Hard Time Creating URL for Ui page .Its not Working 

Help me Creating url for a Ui Page in Right way . My UI Page : TraceDemo 

Please ,Help me in Triggering Ui page Using Ui Actions Button.

Any Suggestion is Appreciated .

 

Thankyou,

1 ACCEPTED SOLUTION

i tested with other d3.js library and showing me the content, so please validate with your script which you are using on your UI Page. 

 

https://d3js.org/d3.v4.js

 

find_real_file.png

 

If my answer helped you, kindly mark it as correct and helpful.

 

View solution in original post

14 REPLIES 14

share the xml of your ui page and ui action, assuming you are doing it on scoped app

Yes, Both Ui Page and Ui actions on a Scoped app.

Im new to Servicenow , xml update set is quite a work now , have little doubt on how todo . 

I wil share Code of Ui page : Html ,Client Script  and Ui Actions:

               UI PAGE 

 

    Html :

<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<html lang="en">
<head>
<style>
.node {
cursor: pointer;
}

.node circle {
fill: #fff;
stroke: steelblue;
stroke-width: 3px;
}

.node text {
font: 12px sans-serif;
}

.link {
fill: none;
stroke: #ccc;
stroke-width: 2px;
}

</style>
<meta charset="utf-8"/>

<title>Tree Example</title>

<link rel="stylesheet" href="Trace.css"/>
</head>

<body>

<!-- load the d3.js library -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.17/d3.min.js"></script>

<script src="Trace.js"></script>

</body>
</html>
</j:jelly>

 

 

             Client script  :

var treeData = [
{
"name": "Account:Trace",
"parent": "null",
"children": [
{
"name": "Contact: A",
"parent": "Account",
},
{
"name": "Contact: B",
"parent": "Account",
},

{
"name": "Contact: C",
"parent": "Account"
},
{
"name": "Contact: D",
"parent": "Account"
},
{
"name": "Contact: E",
"parent": "Account",
}

]
}
];


// ************** Generate the tree diagram *****************
var margin = {top: 20, right: 120, bottom: 20, left: 120},
width = 960 - margin.right - margin.left,
height = 500 - margin.top - margin.bottom;

var i = 0,
duration = 750,
root;

var tree = d3.layout.tree()
.size([height, width]);

var diagonal = d3.svg.diagonal()
.projection(function(d) { return [d.y, d.x]; });

var svg = d3.select("body").append("svg")
.attr("width", width + margin.right + margin.left)
.attr("height", height + margin.top + margin.bottom)
.append("g")
.attr("transform", "translate(" + margin.left + "," + margin.top + ")");

root = treeData[0];
root.x0 = height / 2;
root.y0 = 0;

update(root);

d3.select(self.frameElement).style("height", "500px");

function update(source) {

// Compute the new tree layout.
var nodes = tree.nodes(root).reverse(),
links = tree.links(nodes);

// Normalize for fixed-depth.
nodes.forEach(function(d) { d.y = d.depth * 180; });

// Update the nodes…
var node = svg.selectAll("g.node")
.data(nodes, function(d) { return d.id || (d.id = ++i); });

// Enter any new nodes at the parent's previous position.
var nodeEnter = node.enter().append("g")
.attr("class", "node")
.attr("transform", function(d) { return "translate(" + source.y0 + "," + source.x0 + ")"; })
.on("click", click);

nodeEnter.append("circle")
.attr("r", 1e-6)
.style("fill", function(d) { return d._children ? "lightsteelblue" : "#fff"; });

nodeEnter.append("text")
.attr("x", function(d) { return d.children || d._children ? -13 : 13; })
.attr("dy", ".35em")
.attr("text-anchor", function(d) { return d.children || d._children ? "end" : "start"; })
.text(function(d) { return d.name; })
.style("fill-opacity", 1e-6);

// Transition nodes to their new position.
var nodeUpdate = node.transition()
.duration(duration)
.attr("transform", function(d) { return "translate(" + d.y + "," + d.x + ")"; });

nodeUpdate.select("circle")
.attr("r", 10)
.style("fill", function(d) { return d._children ? "lightsteelblue" : "#fff"; });

nodeUpdate.select("text")
.style("fill-opacity", 1);

// Transition exiting nodes to the parent's new position.
var nodeExit = node.exit().transition()
.duration(duration)
.attr("transform", function(d) { return "translate(" + source.y + "," + source.x + ")"; })
.remove();

nodeExit.select("circle")
.attr("r", 1e-6);

nodeExit.select("text")
.style("fill-opacity", 1e-6);

// Update the links…
var link = svg.selectAll("path.link")
.data(links, function(d) { return d.target.id; });

// Enter any new links at the parent's previous position.
link.enter().insert("path", "g")
.attr("class", "link")
.attr("d", function(d) {
var o = {x: source.x0, y: source.y0};
return diagonal({source: o, target: o});
});

// Transition links to their new position.
link.transition()
.duration(duration)
.attr("d", diagonal);

// Transition exiting nodes to the parent's new position.
link.exit().transition()
.duration(duration)
.attr("d", function(d) {
var o = {x: source.x, y: source.y};
return diagonal({source: o, target: o});
})
.remove();

// Stash the old positions for transition.
nodes.forEach(function(d) {
d.x0 = d.x;
d.y0 = d.y;
});
}

// Toggle children on click.
function click(d) {
if (d.children) {
d._children = d.children;
d.children = null;
} else {
d.children = d._children;
d._children = null;
}
update(d);
}

 

                                 Ui Action :

function Redirect()
{
alert("hi");
var dialog = new GlideDialogWindow("x_445906_mydemo_Trace.do");
dialog.setTitle("UI Page Opened");
dialog.setPreference("sysparm_id", g_form.getUniqueValue());
dialog.render();
}

 

try to comment the below line in your ui actio, 

 

dialog.setPreference("sysparm_id", g_form.getUniqueValue());

 

you are using setPreference() , so are you using it on your ui page html field or any variable  ? if not then comment it on your ui action and try. 

 

sample code i have sent , which is working on scoped app, just using endpoint of that ui page. 

here it is , i tried on custom app and working. 

 

can you comment the setPreference() line. and try. 

 

function test(){

	var dialog = new GlideDialogWindow("x_43765_testing_mo_testing_custom");
	dialog.setTitle("UI Page Opened");
	//dialog.setPreference("sysparm_id", g_form.getUniqueValue());
	dialog.render(); 
}

 

find_real_file.png

 

 

Hi ,

Commented the setPreference() line. and tried but .Nothing shows in Daialog 

My Ui page consists of this Tree Diagram .

find_real_file.png

But  In dialog.Popup Nothing Is Visible .

find_real_file.png

Did you get Output in Daialog Popup.???

Thankyou