Category Archives: URL API

Creating a custom radio button in MicroStrategy Mobile to change panels

Hello there,

I would like to share this implementation that I did for mobile devices. In this case, I had to create a custom radio button using an HTML Container with CSS and JavaScript to change the panels of a panel stack.

The trick is to create anchors with your URL API parameters to change the panels based on the click of the radio button.

I have one function per button in this case, but you can improve it to use only one.

You just need to create an HTML Container and past this code below:

<!DOCTYPE html>

<html lang="en-gb">

<head>

<meta charset="UTF-8">
<style>

.buttons{

margin-bottom : 1.5em;

}

input[type=radio   ]:not(old){

width     : 2em;

margin    : 0;

padding   : 0;

font-size : 1em;

opacity   : 0;

}

input[type=radio   ]:not(old) + label{

display      : inline-block;

margin-left  : -2em;

line-height  : 1.5em;

}

input[type=radio   ]:not(old) + label > span{

display          : inline-block;

width            : 0.875em;

height           : 0.875em;

margin           : 0.25em 0.5em 0.25em 0.25em;

border           : 0.0625em solid rgb(192,192,192);

border-radius    : 0.25em;

background       : rgb(224,224,224);

background-image :    -moz-linear-gradient(rgb(240,240,240),rgb(224,224,224));

background-image :     -ms-linear-gradient(rgb(240,240,240),rgb(224,224,224));

background-image :      -o-linear-gradient(rgb(240,240,240),rgb(224,224,224));

background-image : -webkit-linear-gradient(rgb(240,240,240),rgb(224,224,224));

background-image :         linear-gradient(rgb(240,240,240),rgb(224,224,224));

vertical-align   : bottom;

}

input[type=radio   ]:not(old):checked + label > span{

background-image :    -moz-linear-gradient(rgb(224,224,224),rgb(240,240,240));

background-image :     -ms-linear-gradient(rgb(224,224,224),rgb(240,240,240));

background-image :      -o-linear-gradient(rgb(224,224,224),rgb(240,240,240));

background-image : -webkit-linear-gradient(rgb(224,224,224),rgb(240,240,240));

background-image :         linear-gradient(rgb(224,224,224),rgb(240,240,240));

}

input[type=radio]:not(old):checked +  label > span > span{

display          : block;

width            : 0.5em;

height           : 0.5em;

margin           : 0.125em;

border           : 0.0625em solid rgb(115,153,77);

border-radius    : 0.125em;

background       : #000;

}
</style>

<script>

function clickLvl() {

var event = document.createEvent('MouseEvent');

event = new CustomEvent('click');

var a = document.getElementById('lvlLink');

a.dispatchEvent(event);

}

function clickVP() {

var event = document.createEvent('MouseEvent');

event = new CustomEvent('click');

var a = document.getElementById('vpLink');

a.dispatchEvent(event);

}

function clickDivision() {

var event = document.createEvent('MouseEvent');

event = new CustomEvent('click');

var a = document.getElementById('divisionLink');

a.dispatchEvent(event);

}

function clickDepartment() {

var event = document.createEvent('MouseEvent');

event = new CustomEvent('click');

var a = document.getElementById('departmentLink');

a.dispatchEvent(event);

}

function clickClass() {

var event = document.createEvent('MouseEvent');

event = new CustomEvent('click');

var a = document.getElementById('classLink');

a.dispatchEvent(event);

}

</script>

</head>

<body>

<a id="lvlLink" href="mstr://?evt=2048076&psName=ttl|comp&pName=Panel3531|Panel3531"></a>

<a id="vpLink" href="mstr://?evt=2048076&psName=ttl|comp&pName=Panel3535|Panel3535"></a>

<a id="divisionLink" href="mstr://?evt=2048076&psName=ttl|comp&pName=Panel3534|Panel3534"></a>

<a id="departmentLink" href="mstr://?evt=2048076&psName=ttl|comp&pName=Panel3533|Panel3533"></a>

<a id="classLink" href="mstr://?evt=2048076&psName=ttl|comp&pName=Panel4483|Panel4431"></a>
<div class="buttons">
<div>

<input id="radio1" type="radio" name="radio" value="1" checked="checked" onclick="clickLvl()"><label for="radio1"><span><span></span></span>Button 1</label></div>
<div>

<input id="radio2" type="radio" name="radio" value="2"><label for="radio2" onclick="clickVP()"><span><span></span></span>Button 2</label></div>
<div>

<input id="radio3" type="radio" name="radio" value="3"><label for="radio3" onclick="clickDivision()"><span><span></span></span>Button 3</label></div>
<div>

<input id="radio4" type="radio" name="radio" value="4"><label for="radio4" onclick="clickDepartment()"><span><span></span></span>Button 4</label></div>
<div>

<input id="radio5" type="radio" name="radio" value="5"><label for="radio5" onclick="clickClass()"><span><span></span></span>Button 5</label></div>
</div>
</body>

</html>

Each input is a different radio button.

Just let me know if you need help with this code.

Hope it helps.

God bless you!

URL API to renew Mobile cache

Hello there,

Today let’s talk about how to force the mobile app to get the new cache from IS using an URL API.

To do that, just add one of those URLs as a link:

mstr://?evt=2048030&useCache=0, refresh against data warehouse and generate new cache in Intelligence Server. 

mstr://?evt=2048030, refresh against existing Intelligence Server cache;

mstr://?evt=2048030&useCache=1, refresh against existing Intelligence Server cache;

mstr://?evt=2048030&useCache=, refresh against existing Intelligence Server cache;

Hope it helps!

God bless you!

Source: https://community.microstrategy.com/t5/SDK/TN44852-How-to-Purge-Server-Cache-and-Refresh-a-Report-Service/ta-p/194578

Dynamic URL API for HTML Container

Hello there!

Today let’s talk about a quick tip: how to create a dynamic url api for HTML Container.

For J2ee you can do it:

./mstrWeb?Server={&SERVERNAME}&Project={&PROJECT}& …

Where is the rest of the parameters for the url.

For IIS:

./Main.aspx?Server={&SERVERNAME}&Project={&PROJECT}& …

pic

Hope it helps!

God bless you!

PHP Function for get a session using TASK API with IIS

Hello there!

I’ve created a PHP function to help you create a session using TASK API for PHP with IIS.

Here is the code:

<?php

function authenticationMSTR($server, $project, $user, $pass, $documentId, $dashboardMode) {
$projectUrl = str_replace(" ","%20",$project);
$projectTask = str_replace(" ","+",$project);
$username = 'username';
$password = 'password';

$context = stream_context_create(array(
'http' => array(
'header' => "Authorization: Basic " . base64_encode("$username:$password")
)
));

$url = file_get_contents("http://$server/MicroStrategy/asp/TaskAdmin.aspx?
taskId=getSessionState&taskEnv=xml&taskContentType=xml&server=$server&project=$
projectTask&uid=$user&pwd=$pass");

$data=simplexml_load_string($url);

foreach($data->children() as $child) {
foreach($child->children() as $child1) {
$sessionmstr = $child1;
break;
}
}

echo "http://$server/MicroStrategy/asp/Main.aspx?evt=2048001&src=Main.aspx.2048001&visMode=0&currentViewMedia=$dashboardMode&documentID=$documentId&server=$server&Project=$projectUrl&port=0&share=1&hiddensections=header,path,dockTop,dockLeft,footer&usrSmgr=$sessionmstr";
}
}
?>

Where:

$server: is your server ip/dns
$project: Name of the project
$user: MicroStrategy Username
$pass: MicroStrategy Username Password 
$documentId: Document ID
$dashboardMode: View media. Example: Use 8 for flash and 2 for DHTML.
$username = Put the Username for login in your TaskAdmin page. 
$password = Put the password for the Username used to login in TaskAdmin page.

Just save this in a file as Authentication.php. Now create another file like this:

<?php
include "Authentication.php";
?>
<html>
<head>
<title>Title</title>
<?php header("Content-Type: text/html; charset=ISO-8859-1",true);?>
</head>

</html>

Just use your own info in those above parameters.

Save this file as test.php in the same folder that you saved your Authentication.php.
Those files must be saved inside your Apache PHP folder. If you use Xampp, is must be saved inside the htdocs folder.

Open test.php in your browser and you will see your dashboard!

 

Hope it helps!

God bless you!

Using Jquery to change IFrame content

Hello there!

Today let’s talk about a cool hack: How to change the IFrame content using JQuery!

I’ve created this code to substitute the Layout feature in Document using IFrame, so when you click on a selector element or image, for example, it will change the IFrame content using the report/document specified for that selector element or image.

You must to execute your document in Interactive Mode to make it works.

To do that you have to:

For images:

1. Create a new document;

2. Insert 1 HTML Container and use it as an IFrame:

pic1

Rick click on the HTML Container inserted and go to Properties and Formatting…

pic1

Choose IFrame and click Ok:

pic1

3. Insert 2 images:

pic1

4. Use Google Chrome or Firefox with Firebug to inspect element to see their ids. In my case, I’m going to use Google Chrome and right click on a blank area to see the image ids.

Execute the document in Interactive Mode -> Right click on a blank area and choose Inspect Element -> Click on the Search button in the inspect section and click on the image -> Get the span id that has the image:

pic1

pic1

pic1

In my case is W46 and W48.

5. Insert another HTML Container and paste this code inside of it. Note that I inserted the W46 and W48 in the click event, you must use your id value. In the http//localhost… you must insert the link to your report/document:

<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script>
$(document).ready(function(){
$('#W46').click(function(){
$('.htmlContIframe').attr('src','http://localhost:8080/MicroStrategy/servlet/mstrWeb?evt=2048001&src=mstrWeb.2048001&visMode=0&currentViewMedia=2&documentID=4E7D7D5B46726C89E069ADBF1CF540AD&server=NB-033&Project=MicroStrategy%20Tutorial&port=0&share=1&hiddensections=header,path,dockTop,dockLeft,footer') ;
});
$('#W48').click(function(){
$('.htmlContIframe').attr('src','http://localhost:8080/MicroStrategy/servlet/mstrWeb?evt=4001&src=mstrWeb.4001&reportID=3D0A29164E09BC1B7733DB99D775B2FD&visMode=0&reportViewMode=1&server=NB-033&Project=MicroStrategy%20Tutorial&port=0&share=1&hiddensections=header,path,dockTop,dockLeft,footer') ;
});
 });
</script>

After you changed the $(“#W48”) and $(“#W46”) to your span id and changed the urls, you can now execute your documet in interactive mode and see that your IFrame will update using each chosen url. Remember to insert:

&hiddensections=header,path,dockTop,dockLeft,footer

After your urls.

pic1

Tip: Set border none in each html container:

pic1

For each button, repeat this code:

$('#W48').click(function(){
$('.htmlContIframe').attr('src','http://localhost:8080/MicroStrategy/servlet/mstrWeb?evt=4001&src=mstrWeb.4001&reportID=3D0A29164E09BC1B7733DB99D775B2FD&visMode=0&reportViewMode=1&server=NB-033&Project=MicroStrategy%20Tutorial&port=0&share=1&hiddensections=header,path,dockTop,dockLeft,footer') ;
});

Just remember to change the W48 id to the id of the span that has your image.

For selectors:

1. Repeat steps 1 and 2;

2. Add a dataset with Country attribute, for example;

3. Create a button bar selector and use Country as source. Disallow multiple selections and remove the All element;

4. Execute your document and see every element that you have in this selector:

pic1

In my case I have USA and Web.

5. Insert a new HTML Container and paste this code:

<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script>
$(document).ready(function(){
$('input[type="button"][value="USA"]').click(function(){
$('.htmlContIframe').attr('src','http://localhost:8080/MicroStrategy/servlet/mstrWeb?evt=2048001&src=mstrWeb.2048001&visMode=0&currentViewMedia=2&documentID=4E7D7D5B46726C89E069ADBF1CF540AD&server=NB-033&Project=MicroStrategy%20Tutorial&port=0&share=1&hiddensections=header,path,dockTop,dockLeft,footer') ;
});
$('input[type="button"][value="Web"]').click(function(){
$('.htmlContIframe').attr('src','http://localhost:8080/MicroStrategy/servlet/mstrWeb?evt=4001&src=mstrWeb.4001&reportID=3D0A29164E09BC1B7733DB99D775B2FD&visMode=0&reportViewMode=1&server=NB-033&Project=MicroStrategy%20Tutorial&port=0&share=1&hiddensections=header,path,dockTop,dockLeft,footer') ;
});
 });
</script>

Just change the USA and Web to your element names. If you have more than 2 elements in your Country attribute, just repeat this code changing the value to the name of your elements:

$('input[type="button"][value="Web"]').click(function(){
$('.htmlContIframe').attr('src','http://localhost:8080/MicroStrategy/servlet/mstrWeb?evt=4001&src=mstrWeb.4001&reportID=3D0A29164E09BC1B7733DB99D775B2FD&visMode=0&reportViewMode=1&server=NB-033&Project=MicroStrategy%20Tutorial&port=0&share=1&hiddensections=header,path,dockTop,dockLeft,footer') ;
});

In this case, for each element that you have in your selector, you can display a different report/dashboard.

pic1

Hope it helps!

God bless you!