cancel
Showing results for 
Search instead for 
Did you mean: 

How to popup a alert for error username/password?

Former Member
0 Kudos

Hi, experts,

I have create a HWC application with Credential request and ECC backend through SSO.

I hope the Credential request can popup a alert after a user type error username/password in the Credential request screen.

I tried to write code in the customAfterMenuItemClick in the Custom.js, like the following:

function customAfterMenuItemClick(screen, menuItem) {

    if(screen == "Credential_Request" && menuItem == "Save" ){

    .....

   

    }

}

But I failed. How can I do it?

Do you give me some hint?

Best regards,

tao

Accepted Solutions (0)

Answers (3)

Answers (3)

Dan_vL
Product and Topic Expert
Product and Topic Expert
0 Kudos

The above code worked for me in a simple test of a new hybrid app that contained a Credential Request screen.

The following samples may be relevant.

Debugging a Mobile Workflow https://cw.sdn.sap.com/cw/docs/DOC-150957

Credentials in a Mobile Workflow https://cw.sdn.sap.com/cw/docs/DOC-149768

I assume though that your question is how do I handle the case where the user name or password are incorrect.

The following is an excerpt from the section How to Handle Credential Failures in the Credentials in  a Mobile Workflow sample.

Depending on the application, it may make sense to validate the users credentials when they initially log in. To do this, an online request can be invoked to validate the user provided credentials.

An operation will be added to the MBO whose purpose is validate the user name and password provided and not to affect the backend data.

  • Add a new operation to the MoviesToSeeIn2012 MBO named validateLogin of type Other with a definition of SELECT * FROM DUMMY

... see the link above for the complete sample.

Dan_vL
Product and Topic Expert
Product and Topic Expert
0 Kudos

The above code worked for me in a simple test of a new hybrid app that contained a Credential Request screen.

The following samples may be relevant.

Debugging a Mobile Workflow https://cw.sdn.sap.com/cw/docs/DOC-150957

Credentials in a Mobile Workflow https://cw.sdn.sap.com/cw/docs/DOC-149768

I assume though that your question is how do I handle the case where the user name or password are incorrect.

The following is an excerpt from the section How to Handle Credential Failures in the Credentials in  a Mobile Workflow sample.

Depending on the application, it may make sense to validate the users credentials when they initially log in. To do this, an online request can be invoked to validate the user provided credentials. An operation will be added to the MBO whose purpose is validate the user name and password provided and not to affect the backend data.

  • Add a new operation to the MoviesToSeeIn2012 MBO named validateLogin of type Other with a definition of SELECT * FROM DUMMY

  • Redeploy the MoviesToSeeIn2012 choosing the Replace deploy mode.
  • Create a new mobile workflow named Creds2.xbw and check Has setup options that need to be set when the client application is first activated and Credenitals may be requested dynamically from the client application.
  • Add a Start screen, Movies and Movie Details screens as done previously.

  • Add a Success screen.
  • On the Credentials screen add a menu item of type online request which will validate the provided user name and password. Its success screen should be Success and Error screen is Credentials
  • On the Success screen add a menu item of type Submit Workflow. When invoked it will update the credentials cache and close the Credentials flow.
       

Here is the the success screen shown after a valid user id and password has been provided.

   

Hope that helps,

Dan van Leeuwen

midhun_vp
Active Contributor
0 Kudos

The HWC is developed in such a way that once the authentication fails, the credential request screen pops up.

You have to note that the validation happens only when an online query is fired from the device.

Here the save button should make an online call to backed. It the authentication fails, the credential screen pops up