Developer

IBM Maximo: How to add Social Networking buttons to your application

In the past months I designed a solution to integrate IBM Maximo and Twitter to address a common requirement: to notify the users when something happen in IBM Maximo. For example an user group should be notified when an workorder change status. The solution is based on Twitter4J library, a  Java Twitter’s API library.

In this article I’m showing you how to add Social Networking button to your application, for example the Twitter button to your Maximo Service Request (SR) application:

Twitter Button
Twitter Button

 

This feature may address the following Customer’s requirement: sending a notifications for Service Requests ‘s updates. In this scenario instead of to send email notifications for a Service Request I’m showing you how to send a Tweet to notify an user.

 

FIRST of all you have to define a new application in your Twitter account:

 

IBM Maximo Twitter Application definition
IBM Maximo Twitter Application definition

 

to grant the application authorization to post on the user’s behalf. In our scenario the Maximo Java code will post using my Twitter account by Outh authentication. You can easily create an Twitter application in your account here.

 

SECOND you have to extend the TICKET object with two attributes (using Maximo database configuration) :

  • TWITTERACCOUNT (ALN, 15)  to store the Twitter user account
  • TWEETTHISTEXT (ALN, 140) to store the text to tweet

 

THIRD you have to modify the SR application with the following items (using Maximo application designer) :

  • two text field associated with two new attributes created on TICKET object.
  • a button, that is your social network button.
  • a signature to manage the button-pressed event action, see IBM Maximo application developer guide for details.

You can use your Tweet button preferred image in maximo\applications\maximo\maximouiweb\webmodule\webclient\skins\tivoliXY\images ,  remember to rebuild & redeploy the Maximo ear in your Application Server before to use the new SR application.

At the end the SR application looks like this one:

 

IBM Maximo SR application with Tweet Social Button
IBM Maximo Service Request application with Tweet Social Button

 

FOUR you have create a Maximo Java custom action to handle the buttonpressed event. Your class must implement the psdi.common.action.ActionCustomClass interface and it must to implement the applyCustomAction method

 

public class TweetThisTextAction implements ActionCustomClass {


    public void applyCustomAction(MboRemote mbo, Object[] params) throws MXException, RemoteException {
        String ticketnum = mbo.getString("ticketid");
        String twitteraccount = mbo.getString("twitteraccount");
        String tweetthistext = mbo.getString("tweetthistext");
                
        authTwitterApps();
                
        sendTweet(twitteraccount + " about SR: " + ticketnum + " " + tweetthistext);
        
    }

 

I have also used a private method to tweet message

 

public Status sendTweet(String tweet) {
        Status status = null;        
        try {
            status = twitter.updateStatus(tweet);
            System.out.println("Successfully updated the status: " + tweet);            
        } catch (TwitterException te) {
            te.printStackTrace();
            System.out.println("Failed: " + te.getMessage());            
        }
        return status;
    }

 

the complete and tested Java class here [wpfilebase tag=file id=1 tpl=download-button /]

Last step before to use the new social button is to define the custom action using the signature name previously defined in SR application design (using Maximo action application) :

 

Java Custom Action used to tweet
Java Custom Action used to tweet

 

Finally I pressed on my Social button to tweet to @gmnesodo user using my personal account linked to Maximo application:

 

Tweet from Maximo SR
Tweet from Maximo SR

 

So the tweet is composed by the Service Request number and the text (Everything in its Right Place, “Radiohead, Op. Cit.”) previously inserted in SR application’s field.

Enjoy using social networking button in IBM Maximo, your comments and suggestions are welcome.

Related Articles

9 Comments

Back to top button