cancel
Showing results for 
Search instead for 
Did you mean: 

SUP passing data from one screen to another?

Former Member
0 Kudos

Hi,

I am new to the SUP,and wan to know that How do you pass data between screens?

I want to transfer some data or text from first screen to next one.

Also What are custom Actions below Menu section in Workflow Editor Form

and How do it work in SUP?

Regards,

Avinash

Accepted Solutions (1)

Accepted Solutions (1)

Jitendra_Kansal
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Avinash,

for better understanding , refer below link:

http://scn.sap.com/community/developer-center/mobility-platform/blog/2012/07/30/a-workflow-applicati...

Regards,

Jitendra

Answers (2)

Answers (2)

david_brandow
Contributor
0 Kudos

I am new to the SUP,and wan to know that How do you pass data between screens?

I want to transfer some data or text from first screen to next one.

Just to follow up on earlier replies, data stays resident in memory as you transition from one screen to another. There is only one HTML file, so you don't have the traditional problem of needing to come up with a system for transmitting data.

Most, if not all, of your data will end up being stored in the in-memory workflow message (c.f. WorkflowMessage.js). Without going into too many details, the workflow message has a top-level MessageValueCollection and, depending on the structure of your application, may have nested MessageValueCollections as well.  Each screen, when opened, will have the concept of the "current" MVC. For example, the first screen's current MVC will be the root MVC, but if you go to a listview and then click on one of those rows to go to the details screen for that row, that details screen's current MVC will be a nested MVC. Each MVC will contain, among other things, name-value pairs wrapped inside a MessageValue (e.g. "Department_deptId_attribKey", "101").

midhun_vp
Active Contributor
0 Kudos

Hi David,

As you said if mvc will be filled each time.

In the given below code why id value is always 0.

Where key433 is MBO name.

function customAfterDataReceived(incomingWorkflowMessage) {

var mvc = incomingWorkflowMessage.getValues();

 

          var list;

var id =0;

          if(list = mvc.getData("key433")){

var =1;

}

}

Regards

Midhun

david_brandow
Contributor
0 Kudos

I'm really not sure what that code is intended to do, but I don't think its going to operate the way you intend it to, that's for sure. If you can elaborate on what you are trying to accomplish, it should be easier for me to help.

Some general tips that may, or may not, be helpful, depending on what it is you are trying to do:

The first thing to understand is that only keys that is mapped to backend data will actually be sent. If you have a key which is not marked 'Sent by server', then it won't be in the message, it will instead be created on demand on the client.

The next thing you'll need to check is that you have the key name correct. You can check the Output Keys of your object query action/menuitem/button. You can also iterate through the entries in the MVC to see what keys it actually does have, that's obviously the foolproof method.

The next thing I'd point out is that if you want to determine whether a message value (which you have previously determined is not undefined or null) is a list or not, you'll want to call the getType() method of MessageValue and check to see if the type is MessageValueType.LIST or not.

Finally, its usually bad form, at the very least, to put a single equals sign in an 'if' statement.

midhun_vp
Active Contributor
0 Kudos

Thanks David. The key that I given is a client initiated one. As you said it should be sent by server.

The code I given is a part of my code.

And I have one more question that is when the user clicks on one of the message (Push notification) in the application how to detect it. I have a requirement that is once the user clicks on one of the message to open it I want to perform an online request and customafterupdateUI.

Now what I did id that in custombefore showscreen I am calling an online method menuitemcallbackGetItem();

and in customafterUpdateUI() I am calling respective currentmessagevaluecollection and customizing the screen.

In the normal flow of the screen it is working fine. But when I open the screen by clicking the message the screen is not showing. i am getting an error "undefined"

Please give a solution for this.

Thanks

Midhun

david_brandow
Contributor
0 Kudos

When a notification is opened, it will call onWorkflowLoad, which will call processWorkflowMessage, which will call customAfterDataReceived. That's not the only place to do it, of course, but its a reasonably convenient location.

The most likely explanation is that your JS code is throwing an exception.  Try wrapping it in a try-catch-alert block and see where its going wrong.

midhun_vp
Active Contributor
0 Kudos

Hi Avinash,

You have to write a few lines of code to pass data between screens in the custom.js file.

You can get the data in the current screen through the given code:

function customValidateScreen(screenKey, values) {

 

 

          if(screenKey === "Start_List")

          {

 

          var form = document.forms[screenKey + "Form"];

          if(form){

 

          Number = form.Start_Items_NUMBER_attribKey.value;

        

 

          }

          }

There by you can use the fetch the data from a screen. Declare the Number as a global variable and

access the value of it in any screens.

Else if you want use the keys of one screen in other means you have to connect those screen through a "Go to" control and hide the menuitem created ("Open_screenKey"). Then the keys in one screen will be available in other screen.

And finally the custom action is same as menu. The custom actions won't be visible in the screen as a menu item or button. It used in the custom code that we write in the custom.js.

Regards

Midhun