# How to get the control values from form to class

**URL:** <https://www.dynamicsuser.net/t/how-to-get-the-control-values-from-form-to-class/66254>\
**Category:** Developer Forum\
**Created:** [November 13, 2018, 7:05am UTC](https://www.dynamicsuser.net/t/how-to-get-the-control-values-from-form-to-class/66254 "2018-11-13T07:05:12Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![SivaRaman](https://avatars.discourse-cdn.com/v4/letter/s/bc8723/32.png) [@SivaRaman](https://www.dynamicsuser.net/u/SivaRaman)\
**Post date:** [November 13, 2018, 7:05am UTC](https://www.dynamicsuser.net/t/how-to-get-the-control-values-from-form-to-class/66254/1 "2018-11-13T07:05:12Z")

</div>

Hi Friends,

I am having a string control field in my form. I want to pass the value which is given in that control fields to class.

can anyone suggest?

---

<div class="post-metadata">

**Author:** ![kranthi](https://avatars.discourse-cdn.com/v4/letter/k/e480ec/32.png) [@kranthi](https://www.dynamicsuser.net/u/kranthi)\
**Post date:** [November 13, 2018, 7:32am UTC](https://www.dynamicsuser.net/t/how-to-get-the-control-values-from-form-to-class/66254/2 "2018-11-13T07:32:57Z")

</div>

How are you calling the class from that form? Please elaborate.

Is that string control a bound field?

---

<div class="post-metadata">

**Author:** ![SivaRaman](https://avatars.discourse-cdn.com/v4/letter/s/bc8723/32.png) [@SivaRaman](https://www.dynamicsuser.net/u/SivaRaman)\
**Post date:** [November 13, 2018, 7:57am UTC](https://www.dynamicsuser.net/t/how-to-get-the-control-values-from-form-to-class/66254/3 "2018-11-13T07:57:24Z")

</div>

Thanks for the reply Krnathi.

Is that string control a bound field?

No Krnathi. It just an unbound field for user entry which is created by me.

How are you calling the class from that form?  
I am calling the class on the normal button click event.

---

<div class="post-metadata">

**Author:** ![kranthi](https://avatars.discourse-cdn.com/v4/letter/k/e480ec/32.png) [@kranthi](https://www.dynamicsuser.net/u/kranthi)\
**Post date:** [November 13, 2018, 8:02am UTC](https://www.dynamicsuser.net/t/how-to-get-the-control-values-from-form-to-class/66254/4 "2018-11-13T08:02:57Z")

</div>

> [@](#):
>
> I am calling the class on the normal button click event.

Can you show your code in clicked method?

Have you tried using parm method?

---

<div class="post-metadata">

**Author:** ![SivaRaman](https://avatars.discourse-cdn.com/v4/letter/s/bc8723/32.png) [@SivaRaman](https://www.dynamicsuser.net/u/SivaRaman)\
**Post date:** [November 13, 2018, 8:22am UTC](https://www.dynamicsuser.net/t/how-to-get-the-control-values-from-form-to-class/66254/5 "2018-11-13T08:22:22Z")

</div>

void clicked()  
{

ProductCallingExtends extend = ProductCallingExtends();  
super();

extend.main();  
}

The above is my clicked method. How can I pass the value? My control field name is “Name”.

Have you tried using parm method?

shall you give any example?

---

<div class="post-metadata">

**Author:** ![MartinDrab](https://avatars.discourse-cdn.com/v4/letter/m/e0b2c6/32.png) [@MartinDrab](https://www.dynamicsuser.net/u/MartinDrab)\
**Post date:** [November 13, 2018, 8:39am UTC](https://www.dynamicsuser.net/t/how-to-get-the-control-values-from-form-to-class/66254/6 "2018-11-13T08:39:15Z")

</div>

Please compile your code to find compilation errors. You forgot the ‘new’ keyword.

```auto
ProductCallingExtends extend = new ProductCallingExtends();

```

In general, if you want to pass something to an object, you call a method and pass the data through a parameter. Like this:

```auto
o.myMethod('data');

```

There is a common pattern for methods just getting and setting values: [parm methods](https://docs.microsoft.com/en-us/dynamicsax-2012/developer/best-practices-for-accessor-methods).

Therefore if you want to create an instance and pass some data to it, you can do this:

```auto
ProductCallingExtends extend = new ProductCallingExtends();
extend.parmSomeValue('xyz');

```

Note there is one more option - you could initialize the value directly in constructor:

```auto
ProductCallingExtends extend = new ProductCallingExtends('xyz');

```

To get the value from your unbound control, change its _AutoDeclaration_ property to _Yes_. Then you can use the object in code. Like this:

```auto
str nameValue = Name.text();

```

Now we can put it all together:

```auto
ProductCallingExtends extend = new ProductCallingExtends();
extend.parmName(Name.text());

```

---

<div class="post-metadata">

**Author:** ![SivaRaman](https://avatars.discourse-cdn.com/v4/letter/s/bc8723/32.png) [@SivaRaman](https://www.dynamicsuser.net/u/SivaRaman)\
**Post date:** [November 13, 2018, 9:33am UTC](https://www.dynamicsuser.net/t/how-to-get-the-control-values-from-form-to-class/66254/7 "2018-11-13T09:33:03Z")

</div>

Hi Martin,

Please compile your code to find compilation errors. You forgot the ‘new’ keyword.  
Thanks for this. At the same time, I am having a new keyword in my code. This is my mistake, when I have edited the code for showing to Kranthi, I missed that. I will correct it.

Thanks for giving this brief solution for me.

---

<div class="post-metadata">

**Author:** ![kranthi](https://avatars.discourse-cdn.com/v4/letter/k/e480ec/32.png) [@kranthi](https://www.dynamicsuser.net/u/kranthi)\
**Post date:** [November 13, 2018, 9:37am UTC](https://www.dynamicsuser.net/t/how-to-get-the-control-values-from-form-to-class/66254/8 "2018-11-13T09:37:39Z")

</div>

Main is a static method, (see the below example)

Args args = new Args();

args.parm(Name.text());  
ProductCallingExtends::main(args);

---

<div class="post-metadata">

**Author:** ![SivaRaman](https://avatars.discourse-cdn.com/v4/letter/s/bc8723/32.png) [@SivaRaman](https://www.dynamicsuser.net/u/SivaRaman)\
**Post date:** [November 13, 2018, 9:44am UTC](https://www.dynamicsuser.net/t/how-to-get-the-control-values-from-form-to-class/66254/9 "2018-11-13T09:44:04Z")

</div>

Thank you very much Kranthi and Martin. That is worked for me.

Below is my code:

void clicked()  
{  
str name1;  
ProductCallingExtends extend = new ProductCallingExtends();  
super();  
name1 = Name.text();  
extend.gettingfromform(name1);  
}

---

<div class="post-metadata">

**Author:** ![MartinDrab](https://avatars.discourse-cdn.com/v4/letter/m/e0b2c6/32.png) [@MartinDrab](https://www.dynamicsuser.net/u/MartinDrab)\
**Post date:** [November 13, 2018, 10:55am UTC](https://www.dynamicsuser.net/t/how-to-get-the-control-values-from-form-to-class/66254/10 "2018-11-13T10:55:04Z")

</div>

When your question gets answered, please don’t forget to verify answers. It will make clear that the thread doesn’t need attention anymore and others looking for answers will be able to find the easily.

Also, please use _Insert \> Insert code_ to paste source code. It preserves indentation, making code easier to read.

---

<div class="post-metadata">

**Author:** ![SivaRaman](https://avatars.discourse-cdn.com/v4/letter/s/bc8723/32.png) [@SivaRaman](https://www.dynamicsuser.net/u/SivaRaman)\
**Post date:** [November 13, 2018, 11:11am UTC](https://www.dynamicsuser.net/t/how-to-get-the-control-values-from-form-to-class/66254/11 "2018-11-13T11:11:08Z")

</div>

Ok, Martin. I got it.
