cancel
Showing results for 
Search instead for 
Did you mean: 

How to get login crenditials(Result) from the MBO in a js file

Former Member
0 Kudos

Hi Experts,

    I got a table from oracle db, and i have deployed it and MBO is generated.

That table contains the login credentials which i am giving in the login page.

      I have created a login page with user id and password when i am trying to login by using the credentials which i have registered earlier the credentials are being checked in the table and it should return me yes or no if yes i have to move to next screen if no i should display some alert . My problem is that i am not knowing how to get that verified credentials and display them in my code. I am writing this line of code in java script and i am unable to know, how to handle the data after being checked from the MBO .. please help me out of this ..

Accepted Solutions (0)

Answers (2)

Answers (2)

Virinchy
Active Contributor
0 Kudos

Try changing this function in your custom.js file

function customBeforeSubmit(screenKey, actionName, workflowMessageToSend) {

  if(screenKey === 'SCREENKEYNAME')

  {

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

  if (form) {

/*User_Name is username edit box key name*/

  var username = form.User_Name.value;

/*password is password edit box key name*/

  var password = form.password.value;

  }

  }

  return true;

  }

change the SCREENKEYNAME ,User_Name ,password, hardcoded username, hardcoded password accordingly

Now the user name and password entered by user are in variables username and password. play with that accordingly

Former Member
0 Kudos

Hi viru,

    when i am hardcoding login crenditials it is working,but i want get from MBO its not working.

     How to did the above one,if u have answer if u have plz let me know .

  Thanks & Regards,

   Lokesh Reddy G,

    9700414490.

Jitendra_Kansal
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Lokesh,

You can write an object query for checking the credentials details.

  • Right click mbo>Attributes>Object query>Add
  • Add 2 parameters, give some name like usernameParam and passwordParam
  • Map these parameters to respective fields like username and password(from MBO)
  • Generate object query


     e.g. select x.username, y.password from ABC where x.username=:usernameParam and      y.password=:passwordParam

  • select Return type"as single object""

(assuming username and password are the parameters defined in the mbo ABC.)

  • redeploy mbo
  • call this object query to Login button and do all required mappings

For verification, if details are/not available in backend

You have to write some piece of code in customBeforeNavigateForward

e.g.

hwc.customBeforeNavigateForward = function(screenKey, destScreenKey) {

if(destScreenKey="Employee" && screenKey=="Start"){

//Here Employee is the MBO name

alert("test");

var message = getCurrentMessageValueCollection();

alert("test1");

var itemList = message.getData("Employee");

alert("test2");

var items = itemList.getValue();

var noOfItems = items.length;

alert("noOfItems="+noOfItems);

if(noOfItems==0){

alert("Invalid input");

return false;

}

}

Rgrds,

Jitendra

Former Member
0 Kudos

Hi jitendra,

    What were told above,i have through parameters and again, i am not getting any output with code.

  I am getting the error below shown,

  

                 cannot call method 'get value' of undefined.

   How to resolve the above error,if u have any options to send please let me know.

  Thanks & Regards,

   Lokesh Reddy G.

    9700414490.

Jitendra_Kansal
Product and Topic Expert
Product and Topic Expert
0 Kudos

Can you share the code what you have written? Also share screenshots of app development for screens

Former Member
0 Kudos

Hi Jitendra,

This is the code in Custom.js as below shown,

if(destScreenKey="Third_Screen" && screenKey=="Start"){

        try {

            //Here Employee is the MBO name

            alert("test");

            

            var message = getCurrentMessageValueCollection();

            alert("test1");

            

            var itemList = message.getData("Registration");

            alert("test2");

            

            var items = itemList.getValue();

            var noOfItems = items.length;

            alert("noOfItems="+noOfItems);

            if(noOfItems==0){

            alert("Invalid input");

            return false;

            }

       

       

        } catch (e) {

            alert(e);

            // TODO: handle exception

        }

    }

   This is process we have done,but we are not getting,please let me know if u have any solutions ASAP.

  Thanks & Regards,

   Lokesh Reddy G,

    9700414490.