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!

Link to different reports in a grid/graph

Hello there!

Today I’m going to talk about how to link to different reports/documents using the same grid/graph without any intervention from the user.

As you may know, when you create a link to a report/document in a grid/graph you can specify more than one hyperlink. But, when the user clicks on a specific item, it shows all hyperlinks and he/she has to choose which hyperlink to click on.

What if you must go to a specific report/document for item A, to another for item B, etc, and if the user choose a wrong one, the result is going to be wrong…

So… Let’s do that!

I’m going to use SQL SERVER as my Data warehouse in this example. The syntax may vary if you use different Database.

1. I’m going to create 2 reports that’s going to be used as the link.

2. Get the ID of them. To do that, you can use MicroStrategy Developer, right click on the report 1 -> go to Properties -> Copy the content of the ID field. In my case, for report 1 the ID is 6360D76C4D340D8B79D988A9A759485B and for report 2 is 8F43AC804E18E30709B73DAB83413D00.

3. Now, I’m going to create a FreeForm SQL report using this SQL:

SELECT a11.[CATEGORY_DESC] as CATEGORY_DESC,
CASE
a11.[CATEGORY_DESC]
WHEN 'Book' THEN ('6360D76C4D340D8B79D988A9A759485B')  
WHEN 'Electronics' THEN ('8F43AC804E18E30709B73DAB83413D00')  END 
FROM [LU_CATEGORY] a11

In my CASE statement, I’m specifying to Microstrategy which report has to be used for each specific category.

Now, create 2 managed atributes for that FreeForm.

ID_REPORT     attribute form: ID

ID_REPORT_DESC     attribute form: DESC

And then save it as baseReport.

4. Create a new dashboard and insert a Vertical Bar Graph using the baseReport as the source.

5. Create a Panel Stack and set it as an Information Window.

6. Now, I will use Microstrategy Web to see the links to my reports. To do that, just browse the folders until you see your saved reports -> Right click on Report 1 -> Go to Share -> Show Link -> Copy the content of it.

7. Copy the link an replace the reportID with {ID_REPORT_DESC}:

http://localhost/MicroStrategy/asp/Main.aspx?evt=4001
&src=Main.aspx.4001&
reportID=6360D76C4D340D8B79D988A9A759485B
&visMode=0&reportViewMode=1
&server=SERVER195&Project=EXAMPLE01&port=0&share=1

Just change the reportID content to {ID_REPORT_DESC}.

http://localhost/MicroStrategy/asp/Main.aspx?evt=4001
&src=Main.aspx.4001&
reportID={ID_REPORT_DESC}
&visMode=0&reportViewMode=1
&server=SERVER195&Project=EXAMPLE01&port=0&share=1

Insert an HTML Container object inside the Information Window Panel Stack and add the <a> HTML tag to create a link. Something like this:

 <a href="http://localhost/MicroStrategy/asp/Main.aspx?evt=4001
&src=Main.aspx.4001&reportID={ID_REPORT}&visMode=0
&reportViewMode=1&server=SERVER195
&Project=EXAMPLE01&port=0&share=1" target="_blank">Link</a>

I just added target=”_blank” to open the link in another window. If you don’t want that, just remove it.

“Link” is the static text that will appears after you click on the bar of your graph, you can change to another

Right click on the attribute of the graph -> Click on “use as selector” and target the panel stack that was used as the Information Window.

 

Hope it helps.

God bless you!

Dropdown with multiple selections

Hello there,

Today I’m going to show a hack of  how to allow multiple selections using a dropdown.

Felipe César sent me that tip. Thank you, Felipe. I really appreciate that.

To create this dropdown you will need to:

  1. Create a Dropdown selector as usual;
  2. Right click on the selector and select Properties and formatting;
  3. Go the Layout and select from the DHTML style “Listbox” and check “Allow multiple selections”
  4. Go to Theme and select Light Theme
  5. Go back to Layout and select Dropdown
  6. Go back to Theme and select None
  7. Click OK and you will have something like this:

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!