Skip to Content
author's profile photo Former Member
Former Member

how to define a variable on a controller that has not yet been loaded on a view.

hello experts,

I am facing an issue, when I am trying to use a particular variable on a detail page(variabe is Salesorder), the error is that salesorder is not defined.

But, I have defined the variable in the master page's controller itself.

Now, when I click a particular button, it doesn't loads the master and details page, but it gives an error that sales order is not defined, since master page's controller is called first.

Here are the screen shots:

detail page

Master .controller

Outputscreen

pastedImage_0.png (33.2 kB)
pastedImage_1.png (32.5 kB)
pastedImage_2.png (719.3 kB)
Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

5 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Oct 12, 2015 at 07:25 AM

    hi sanjo..

    why don't you define odata service in your master controller...itself!!

    oDataModel.read("/SalesOrderHeaderDetailsInfoSet?$filter= ImSalesorder eq '"+salesOrder+"'and ImUsername eq '"+data.userName+"' ",null,null,false,onSuccessLogin,function(oError){

    console.log("error",oError);});

    //

    var json = new sap.ui.model.json.JSONModel();

    json.setData({data1:loginResult.results});

    sap.ui.getCore().byId("infoList1").setModel(json);

    Hope it's works!!!😊

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Oct 09, 2015 at 05:13 PM

    why dont you just pass SalesOrder as 3rd param to toDetail

    toDetail("","", { SalesOrder : SalesOrder });

    * @param {object} oData * This optional object can carry any payload data which should be made available to the target page. The "beforeShow" event on the target page will contain this data object as "data" property. * * Use case: in scenarios where the entity triggering the navigation can or should not directly initialize the target page, it can fill this object and the target page itself (or a listener on it) can take over the initialization, using the given data. *
    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 09, 2015 at 05:08 PM

    Hi Sanjo,

    According to your query, what i am getting is that you want to use the variable defined in the Master page onto the detail page.

    So, If my understanding is correct, you need to pass this variable from master view to detail view while navigating.

    I would not suggest and even not recommended to define the variable globally until n unless you did not find any other way to crack it.

    Hope this helps!!! 😊

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Oct 09, 2015 at 12:01 PM

    hi,

    use require to load the controller in order!

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 12, 2015 at 06:14 AM

    HI maksim, I am very new to this, could you please explain in detail how to pass the parameter?

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.