Tag Archives: sdk

Default selection on a Radio Button selector

Hello there,

Recently I was having issues with a selector that was selecting a radio button but it wasn’t selecting the first element by default and I couldn’t use a slice selector to solve that issue. So, I had to implement this code to do it using javascript.

It is very simple, you just need to insert an HTML Container and add this code to it:


<script type="javascript">

radioButtonIndex = 0; // change here the index if you have more than 1 radiobutton selector

document.body.addEventListener('mouseover',modifySelection,true);

function modifySelection(){ 

 radioButtonObj = document.querySelectorAll('[name='+ document.getElementsByClassName('mstrmojo-ListBase mstrmojo-RadioList')[radioButtonIndex].getAttribute('id') +']');

 selected = false;

  for(i = 0; i < radioButtonObj.length ; i++) {

	selected = radioButtonObj[i].checked;

	if(selected == true) {break;}

  }

	if(selected == false){
		radioButtonObj = mstrmojo.all[document.getElementsByClassName('mstrmojo-ListBase mstrmojo-RadioList')[radioButtonIndex].getAttribute('id')];
		radioButtonObj.selectedIndex = 0;
		radioButtonObj.value = 1;
		radioButtonObj.idx = 0;
		radioButtonObj.checked = true;
		radioButtonObj.onchange();
	}
}

</script>

You just need change the radioButtonIndex in case you have more than 1 radio button in your dashboard. Just test 0, 1, 2… until you find the right one.

Hope it helps.

God bless you!

Modifying the iPad/iPhone Mstr mobile app settings programatically

Hello there,

Today let’s talk about how to change the MicroStrategy Mobile app settings using Objective C. To do that you will have to use the latest XCode version and the latest MicroStrategy Mobile SDK version as well. Currently I used XCode 8.2.1 and MicroStrategy Mobile SDK 10.4

I had to modify the app to Offline Mode when the user is not connected to the VPN and I couldn’t the code to do that. So, to help you guys, here I’ll explain how to turn on/off the offline mode and how to change the other options too.

First things first.

Step 1: You have to create a custom app delegate class: https://lw.microstrategy.com/msdz/MSDL/104/docs/projects/MobileSDK/Default.htm#topics/iOS/iOS_Adding_Functionality_with_a_CustomApplDelegate.htm?Highlight=creating a custom

Step 2: Add the BooleanPreference.h file to the Custom Folder:

Just right click on the Custom folder and select “New File”and create a new header file. The name of the file must be BooleanPreference.h

Copy this content into this file:

#import <Foundation/Foundation.h>
@class MSIDevicePreferences;
@interface BooleanPreference : NSObject {
@private
    NSString* prefID;
    BOOL booleanValue;
    MSIDevicePreferences * __weak parent;
}
@property (nonatomic, copy) NSString* prefID;
@property (nonatomic) BOOL booleanValue;
-(BooleanPreference*)initWithID:(NSString*)_prefID boolValue:(BOOL)_value;
@end

Step 3: Your CustomAppDelegate.h must looks like this:

#import <UIKit/UIKit.h>
#import <MicrostrategyMobileSDK/MSIAppDelegateImpl.h>
#import <MicrostrategyMobileSDK/MSICommanderDelegate.h>
#import <MicrostrategyMobileSDK/MSIPreferencesStore.h>
#import <BooleanPreference.h>
@interface CustomAppDelegate : MSIAppDelegateImpl
@end

Step 4: Your CustomAppDelegate.m must looks like this:

#import “CustomAppDelegate.h”
@implementation CustomAppDelegate
-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
BOOL res = [super application:application didFinishLaunchingWithOptions:launchOptions];
// Retrieve preferences
MSIPreferencesStore *store = [MSIPreferencesStore preferencesStore];
MSIDevicePreferences *dp= [store preferencesCopy];
BooleanPreference *boolPref = [dp getIsOfflineMode]; // Here, instead of using “getIsOfflineMode” you will be able to use the other possible options. Just remove it and start typing again and // XCode will show you the other options here
//Offline Mode on
boolPref.booleanValue = YES;
// Store new preferences
[store storePreferences:dp];
}
@end

That is it.

Hope it helps!

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

God bless you!

Using TASK API getSessionState with .net

Hello there!

One of the coolest things that MicroStrategy can do is the ability to embed reports/dashboards using URL API in  a portal, for example. You just have to copy the link of a report/document and paste it in an HTML code to display them. By default, the user needs to fill the login form to see the report/dashboard. If you don’t want that, you can insert 2 parameters in the URL: uid and pwd, so the user is automatically signed it.

Here is an example of URL API to display a specific dashboard:

http://localhost/MicroStrategy/asp/Main.aspx?evt=2048001&src=Main.aspx.2048001&visMode=0&currentViewMedia=2&documentID=68D3815340CDA9BF858B9EB715EC3A88&server=server1&Project=MicroStrategy%20Tutorial&port=0&share=1&hiddensections=header,path,dockTop,dockLeft,footer&uid=administrator&pwd=123456" width="1024" height="768" />

Everybody knows that using this approach wouldn’t be a good idea, because you show to everyone that sees the code an user to login to your projects. You can hide that login using TASK API. TASK API is an MicroStrategy API that uses Tasks (you can even create your own Tasks) to do some processes. To access TASK API page use one of these URLs:

For ASP.NET: http://localhost/MicroStrategy/asp/TaskAdmin.aspx

For J2EE: http://localhost/MicroStrategy/servlet/taskAdmin

You have to enter an OS (Operational System) user to login to this page. Once logged you have to:

1. Create a getSessionState link. To do that, just follow this TN: https://resource.microstrategy.com/support/Authoring/DisplayTN.aspx?tnkey=31236&formatted=1

2. If you are going to use .net with MicroStrategy Web ASP.NET , you can use this code below in your controller (just substitute the strings like username and password with your own data:

String url="https://localhost/MicroStrategy/asp/TaskAdmin.aspx?taskId=getSessionState&taskEnv=xml&taskContentType=xml&server=server1&project=tutorial&uid=administrator&pwd=thepassword";
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url);
request.Method = "GET";
request.UseDefaultCredentials = true;
request.PreAuthenticate = true;
request.Credentials = new NetworkCredential("username", "password", "domain");
// username and password are information about and Windows account, so you have to insert
 
HttpWebResponse response;
Stream stream;
StreamReader streamReader;
 
response = (HttpWebResponse)request.GetResponse();
stream = response.GetResponseStream();
streamReader = new StreamReader(stream);
 
string stringXml = streamReader.ReadToEnd();
String[] str = new string[] { "<min-state>", "</min-state>" };
 
string[] mstrSession= stringXml.Split(str,3, StringSplitOptions.None);

string url2 = "https://localhost/MicroStrategy/asp/Main.aspx?evt=2048001&src=Main.aspx.2048001&visMode=0&currentViewMedia=2&documentID=8AF8FCJHDY1234125CD&server=server1&Project=tutorial&port=0&share=1&hiddensections=header,path,dockTop,dockLeft,footer&usrSmgr=" + mstrSession[1];
return url2;

Just remember to use your report/document URL .

Just create a view to display this code.

Hope it helps.

 

God bless you!