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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

Getting the value of the FormStringControl

(0) ShareShare
ReportReport
Posted on by 535

I guess I am miss understanding on how to retrieve the value from the text box aka formstringcontrol on the form.  Do I need to declare it to be able to access the control? I figured being on the control it would know the location.

pastedimage1676308421195v1.png

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

    You made a mistake when trying to debug your code. I assume that the form control exists, but an obvious bug is that your consumeSoap variable is empty and trying call the method on null leads to NullReferenceException.

    If Main is an instance method, you must create an instance of ConsumeSoapMichelinFunds and put it into consumeSoap variable before you can call the method.

    If it's a static method, call it as a static method (ConsumeSoapMichelinFunds::Main()).

  • KeithM Profile Picture
    535 on at

    The variable isn't empty when I click the button. The consumeSoap variable is a class instance. The MichelinBillto is the formstringcontrol on the form.

    internal final class ConsumeSoapMichelinFunds
    {
        public void Main(str _args)
        {
    
            ExternalWebServices.GetBDFFund GetBDFFund = new ExternalWebServices.GetBDFFund();
    
            real CoopFunds = 0;
            real AMFFunds = 0;
    
            var tempFund = GetBDFFund.getMichelinFunds(_args,CoopFunds, AMFFunds, "");
    
            Info(strFmt("%1", tempFund));
        }
        }

  • Martin Dráb Profile Picture
    239,018 Most Valuable Professional on at

    If the variable is populated, then you didn't show us your actual code. If it's the case, please show us the right one.

    If it's the correct code, then you're wrong. You don't have any code putting any value to consumesoap variable.

    By the way, use a different name for your method - main() has a special meaning.

  • KeithM Profile Picture
    535 on at

    I have created a Form with 2 FormStringControls on it along with a Button. I want to get the billto formcontrol info into the class method.

    pastedimage1676326456406v1.png

    Form:

    [Form]
    public class MichenlinConsumeForm extends FormRun
    {
    
        [Control("Button")]
        class MichelinSubmit
        {
            /// 
            ///
            /// 
            public void clicked()
            {
                Args args;
                FormRun formRun;
    
                super();
                if(element.args())
                {
                    args = new Args();
    
                    FormRun michform = new FormRun(args);
                    
                    ConsumeSoapMichelinFunds consumesoap;  //class 
    
                    consumesoap.GetBillToInfo(michbillto.text());
                }
    
            }
    
        }
    
    }

    Internal Class:

    using ExternalWebServices;
    using System.ServiceModel;
    
    internal final class ConsumeSoapMichelinFunds
    {
    
        public void Main(str _args)
        {
    
        }
    
        public void GetBillToInfo(str Billto)
        {
            ExternalWebServices.GetBDFFund GetBDFFund = new ExternalWebServices.GetBDFFund();
    
            real CoopFunds = 0;
            real AMFFunds = 0;
    
           var fund = "";
            
            var tempFund = GetBDFFund.getMichelinFunds(Billto,CoopFunds, AMFFunds, "");
    
            Info(strFmt("%1", tempFund));
        }
    
    }

  • Verified answer
    Martin Dráb Profile Picture
    239,018 Most Valuable Professional on at

    You still have the same bug there.

    ConsumeSoapMichelinFunds consumesoap;  // This creates an emoty variable (containing null) 
    consumesoap.GetBillToInfo(...); // Here you're trying to call a method on null, which must fail

    If you want an instance method, you need to create an instance of the class. For example:

    ConsumeSoapMichelinFunds consumesoap = new ConsumeSoapMichelinFunds();
    consumesoap.GetBillToInfo(...);

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 613

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 455 Super User 2026 Season 1

#3
Syed Haris Shah Profile Picture

Syed Haris Shah 292 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans