MSTR - SDK - How-Tos

mstr-sdk

How can we run some code at the time the report is saved?

See MSTR KB36011, and KB20395:

package com.microstrategy.eventhandler;
import com.microstrategy.web.beans.AggregatedEventHandler;
import com.microstrategy.web.beans.RequestKeys;
import com.microstrategy.web.beans.WebEvent;
import com.microstrategy.web.beans.WebException;
public class ReportName extends AggregatedEventHandler { 

    public ReportName() {
        super();
    }
    public boolean processRequest(RequestKeys keys) throws WebException {
        WebEvent event = getWebEvent(keys);
        if(event == null) {
            return super.handleDefaultRequest(keys);
        }

        System.out.println("Event: " + event.getID());
        switch(event.getID()) {
            case 26003 :
             System.out.println(event.getArgumentValue(26003));

                return super.handleDefaultRequest(keys);
            default :
                return super.handleDefaultRequest(keys);
        }

    }
}

To obtain the report object:

rb = (ReportBean) getWebComponent();

To get the ID of the report:

rb.getObjectID()

If we do not know if the report that is being saved is a report or a document, we might want to used:

WebObjectInfo obj = (WebObjectInfo) getWebComponent();

To determine the folder that the report is being saved to, we may want to use the getParent method of the ReportBean object or the WebObjectInfo object.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License