Announcement

Collapse
No announcement yet.

Get model attributes in dynamic controller

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Get model attributes in dynamic controller

    Hello everyone,

    Could you help me with the following problem please. I am creating a dynamic controller for "Case" but when I try to get a model attribute in the following way "this.model.get('type')" or in this way "this.recordView.model.get('type') "The first time I enter a record after rebuilding, deleting the cache and reloading the page, it shows me "undefined" in the console but if I exit and re-enter the same record it shows me the correct data.

    What can I do to always get the correct data?

    this is the code I'm using

    HTML Code:
    define('custom:case-dynamic-handler', ['dynamic-handler'], (Dep) => {
    
        return class extends Dep {
    
            init() {
                this.controlEnum();
            } 
           
            controlEnum() {
                console.log(this.model.get('type'));
                console.log(this.recordView.model.get('type'));
            }
        }   
    });
    Attached Files

  • #2
    Try this.view... (this.view.model etc)

    Comment


    • jgarcia
      jgarcia commented
      Editing a comment
      Thanks for your help, but if I use "this.view.model", "this.view" or "this.view.model.get('type')" I still get the undefined value.

  • #3
    this.model.get('type') should work fine. i have just tested your code on my instance and it works fine. check if the value of type is none

    Comment

    Working...
    X