web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Update control when another changes

(0) ShareShare
ReportReport
Posted on by 6,648

Hi  Guys, 

I have some string edit which are bounded.

I need to, for example when I select first string edit , second string edit fill by default value.I want to change default value of second string edit by selecting first string edit.

5047.1.png 

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Martin Dráb Profile Picture
    237,801 Most Valuable Professional on at

    If I understand your requirement correctly, you don't want to do "Filtering String Edit", which is the title of your question. You want to update Contract field when the value of Company field changes.

    If both fields are from the same table and you can change its code, you can override modifiedField() method, check if the field being changed is Company and then set the value of Contract (this.Contract = "whatever";).

  • Hossein.K Profile Picture
    6,648 on at

    Hi Martin,

    Both of String edit is bounded and are not from the same table and also both of them are filled by lookup method.

    Now , I want to second String edit fill with value instead of "Select contract..."  after selection the first automatically.

  • Suggested answer
    Martin Dráb Profile Picture
    237,801 Most Valuable Professional on at

    If they're from different tables, you shouldn't use modifiedField() on table. But you can override modify() of the form datasouce field and put your logic there. The assignment is trivial:

    nameOfTheDsContainingContract.Contract = "whatever";

    This will set the value to the active record in the datasource called nameOfTheDsContainingContract. I can't be more specific because you didn't mentioned any names.

    By the way, I'll update the title for you to match the actual question.

  • Hossein.K Profile Picture
    6,648 on at

    I face with this error:

    Parentheses are required on a method call. Err:324

    It is my code:

    public void modified()
    {
        super();
        PaymSched_ds.Name=element.design().controlName("ContractName").valueStr();
    }


  • Suggested answer
    nmaenpaa Profile Picture
    101,160 Moderator on at

    If your intention is to put value to field Name of table PaymSched, your syntax should be:

    PaymSched.Name=element.design().controlName("ContractName").valueStr();


    PaymSched_ds.Name() returns the name of your form data source. And if you try to call that method without parenthesis, you will get a syntax error like you did.

  • Hossein.K Profile Picture
    6,648 on at

    Hi Nikolaos,

    My error is solved but value of string edit does not change.

  • nmaenpaa Profile Picture
    101,160 Moderator on at

    What is the data source of your string edit? Are you sure it's PaymSched.Name? I'm not. If we are still talking about the screenshot of your first post, it looks like a payment schedule id, not payment schedule name. And what are you trying to do? Are you trying to create a new payment schedule? Are you trying to update an existing payment schedule? Are you trying to find an existing payment schedule.

    Please share your exact expected outcome.

  • Martin Dráb Profile Picture
    237,801 Most Valuable Professional on at

    Saying "it doesn't change" is not sufficient. Use the debugger to analyze what's going on.

    By the way, why do you use element.design().controlName("ContractName").valueStr() instead of something like myTable.ContractName or at least ContractName.text()? It looks very complicated and error-prone. For example, the code would still compile if you renamed the control but it would throw an exception at runtime.

    If you ever have to use a hard-coded control name, use formControlStr() to get compile-time validation.

  • Verified answer
    Hossein.K Profile Picture
    6,648 on at

    My problem is solved.below is correct code:

    /// <summary>
    /// This function is developed for filling Payment Schedule and Customer Posting Profile according of selection Leasing Contract Automatically.
    /// </summary>
    /// Created by h.karimi 1397/05/23
    ///
    public boolean modified()
    {
        boolean ret;
        
        ;
    
        ret = super();
    
        SalesTable.PaymentSched=element.design().controlName("ContractName").valueStr();
        SalesTable.PostingProfile=LeasingContract.PostingProfile;
        SalesTable_ds.refresh();
        
        return ret;
    }

    Because of the string edit fill in lookup method and data field does not bound,I override modified method of first string edit.
  • Hossein.K Profile Picture
    6,648 on at

    Anyway,Thanks Martin and Nikolaos.

    Your answers was help me for finding solution.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans