cancel
Showing results for 
Search instead for 
Did you mean: 

Create a new Action Inbox Item

Former Member
0 Kudos

Hi,

can anybody tell me how I can create a new item for action inbox via api. The new item should be displayed in an own category.

Has anybody a complete code example. The sap documentation is very short.

Regards,

Gerhard

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Use method,

createItem

public IActionInboxItem createItem(IResourceContext context,
                                   IActionInboxItemProducer producer,
                                   IActionInboxNotification notification,
                                   String linkID)
                            throws WcmException

Create a new item in the item category.

<b>Parameters:</b>

context - the IResourceContext to use for accessing the inbox.

producer - the IActionInboxProducer wich will provide the actions allowed for this item. This producer has to be a registered item producer - if not, an exception will be thrown!

notification - the IActionInboxNotification to store in the inbox category.

linkID - a String with a common link ID to crosslink several items from other item categories to this item or null if no other items are linked.

<b>Returns:</b>

the IActionInboxItem saved.

<b>Throws:</b>

a - WcmException if an error occurred.

WcmException

Have a look at this https://help.sap.com/javadocs/NW04s/current/km/com/sapportals/wcm/service/actioninbox/IActionInboxIt...

for more details.

Regards,

Nitin

Former Member
0 Kudos

Hi Nitin,

thank you for your answer.

Can you please explain how I can create the objects "IActionInboxItemProducer" and "IActionInboxNotification"?

Regards,

Gerhard

Former Member
0 Kudos

https://portal.mydorma.com/irj/portalapps/javadocs/km/com/sapportals/wcm/service/actioninbox/package...

The code sample shows how to register an IActionInboxItemProducer with the action inbox service. The producer is implemented as an MyServicesActionInboxItemProducer.

   IActionInboxService myActionInbox = (IActionInboxService)myResourceFactory.getServiceFactory()
    					.getService(IServiceTypesConst.ACTION_INBOX_SERVICE);
    if( myActionInbox != null ) {
      // create Instance of our item producer
      IActionInboxItemProducer myActionInboxItemProducer = new MyServicesActionInboxItemProducer();
      // register producer at service
      IActionInboxItemCategory myActionInboxCategory = myActionInbox.registerProducer(myActionInboxItemProducer,
    										  "myService"); 
    } else {

    	// We have a problem...
      }

Former Member
0 Kudos

Hi Nitin,

thank you.

Now I have the object "IActionInboxItemProducer". How can I create the Notification object?

Regards,

Gerhard

Former Member
0 Kudos

I dont know why are you looking for exact code? Is it that much hard to write a code with such a help of javadoc?

http://portal.dk.issworld.com:50000/irj/portalapps/javadocs/km/com/sapportals/wcm/service/actioninbo...

Former Member
0 Kudos

Hi Nitin,

thank you!

Now I have following code:

<b>My Item Producer:</b>

package de.oscare.kmc.test;

import com.sapportals.wcm.WcmException;
import com.sapportals.wcm.repository.IResourceContext;
import com.sapportals.wcm.service.actioninbox.IActionInboxAction;
import com.sapportals.wcm.service.actioninbox.IActionInboxItem;
import com.sapportals.wcm.service.actioninbox.IActionInboxItemProducer;

public class ItemProducer implements IActionInboxItemProducer {

	public String getID() {
		return "oscareID";
	}

	public String getItemDescription(IResourceContext arg0, IActionInboxItem arg1) {
		return "oscareItemDescription";
	}

	public boolean executeItemAction(IResourceContext arg0, IActionInboxAction arg1, IActionInboxItem arg2)	throws WcmException {
		return false;
	}

	public void onDeleteItem(IActionInboxItem arg0) {

	}
}

<b>My Notification Class:</b>

package de.oscare.kmc.test;

import java.util.Date;
import java.util.Properties;

import com.sapportals.portal.security.usermanagement.IUMPrincipal;
import com.sapportals.wcm.service.actioninbox.AbstractActionInboxNotification;
import com.sapportals.wcm.util.resource.Descriptions;
import com.sapportals.wcm.util.uri.RID;

public class Notification extends AbstractActionInboxNotification {

	public Notification(String arg0, Descriptions arg1, IUMPrincipal arg2, Date arg3, Properties arg4, String arg5, RID arg6) {
		super(arg0, arg1, arg2, arg3, arg4, arg5, arg6);
	}

}

<b>My method for initialisation:</b>

try {
	IPortalComponentRequest request = (IPortalComponentRequest) this.getRequest();
	com.sapportals.portal.security.usermanagement.IUser user =(com.sapportals.portal.security.usermanagement.IUser) request.getUser().getUser();
	IResource datei = ResourceFactory.getInstance().getResource(RID.getRID("/documents/dummy.txt"), new ResourceContext(user));
	
	IResourceFactory myResourceFactory = ResourceFactory.getInstance();


	IActionInboxService myActionInbox = (IActionInboxService)myResourceFactory.getServiceFactory().getService(IServiceTypesConst.ACTION_INBOX_SERVICE);

	IActionInboxItemProducer myActionInboxItemProducer = new ItemProducer();
	IActionInboxItemCategory myActionInboxCategory = (IActionInboxItemCategory) myActionInbox.registerProducer(myActionInboxItemProducer, "oscareID");
	
	
	myActionInboxCategory.getID();	
	
	Descriptions beschreibung = new Descriptions();
	beschreibung.setDescription(Locale.GERMANY, "Beschreibung...");
	
	
	Notification not = new Notification("oscareID", beschreibung, user, new Date(), null, null, datei.getRID());
	
	myActionInboxCategory.createItem(datei.getContext(), myActionInboxItemProducer,	not , null);

}
catch (Exception e) {
	e.printStackTrace();
	throw new PortalRuntimeException(e);
}

But now I get a NullPointerException when I want to call any method from the object "myActionInboxCategory".

For example in line "

myActionInboxCategory.getID();

"

Do you have any idea?

Regards,

Gerhard