SBX - Search With Button

SBX - Forum Post Title

StringEdit control in form..

Microsoft Dynamics AX Forum

AXTechie2120 asked a question on 11 Oct 2018 8:17 AM
My Badges

Question Status

Suggested Answer

Hi,

I have created a stringedit field in the grid which is not bound to any datasource table,Whenever i enter the data in that field and close that form and reopen it the values is not appearing again.

Can you please tell how to store the value in that  grid even after closing the form.

Please advise.

Regards,

AXTechie2120

Reply
István Orosz responded on 11 Oct 2018 8:25 AM
My Badges
Suggested Answer

Hi,

Do you mean, that the DataSource and the DataField properties are not set for the stringEdit? In this case the grid does not know which table and field should be connected to the stringEdit value.

Reply
Martin Dráb responded on 11 Oct 2018 8:56 AM
Suggested Answer

The best solution is binding the control to a datasource field. If you can't do that for some reason, you'll have to save it somewhere in your own code. But because you'll have to save to a database anyway, using a datasource instead of custom code is likely a better option.

Reply
AXTechie2120 responded on 12 Oct 2018 12:23 AM
My Badges

Thank you guys,

Can you give some example on how to achieve this.

Regards,

Bharath K

Reply
Martin Dráb responded on 12 Oct 2018 1:56 AM

What exactly do you mean by "this"? How to use DataSource and DataField properties to bind a control to a datasource field?

Reply
AXTechie2120 responded on 12 Oct 2018 2:00 AM
My Badges

How to store the value in the form for that stringedit control which is not bound to the datasource  whenever I close the form that value should be stored in that form.

Regards,

AXtechie

Reply
Martin Dráb responded on 12 Oct 2018 2:17 AM

Let me repeat once more that you shouldn't do it at all - if you use the standard functionality, you'll be done in a few seconds and there won't be any custom code that needs to be maintained, that may contain bugs and so on.

If you want to do it anyway, the first step is thinking about where you'll store the data. This is not what we can tell you; it depends on your business requirements.

Obviously you'll need some table, but we don't know whether you want a single, globally shared record, one record for every user, records somehow linked to other data in the form or what. If you're unable to decide, share your business requirements with us so we can help you with the design.

Then your code will find the right record to update (creates a new one if none exists), set the value from the form control to a field and save the record.

If two users can work on the same record, don't forget to check for update conflicts.

Reply
Suggested Answer

In general if you need to store a piece of information in AX, you use a database table and field for that.

If you want to show this data in a form, you use that table as a data source for the form, and create a control that is bound to the field in the data source.

Could you explain why you don't want to use this approach? What is your functional requirement?

Reply
AXTechie2120 responded on 12 Oct 2018 2:36 AM
My Badges

Hi,

I already knew that we store data for a stringedit in the table ,but now is requirement is i want to store the value that we enter first in the form and save should be displayed and editable  and should be present there even after we close and open that form.

But Now what now happening is the value is getting generated and when i reopen that form the value disappers.

I want to know how we can save the stringcontrol without bound to the datasource.

The functional requirement is the client doesn't what that data should be stored in the database since its has large number of records and this stringedit repeats also repeats for that number of records.

Regards,

Ax techie

Reply
Suggested Answer

I still don't understand. If this StringEdit repeats for the number of records, I would say you just need to add one new field to your form data source that represents these records. And bound that field in the StringEdit control.

Or if you want, you can create a new table that is related to the current data source table.

What information is in this string field? And what are the records that are related to it?

If you don't want to store that information in the database, then where? The sole purpose of database is to store data. 

Reply
István Orosz responded on 12 Oct 2018 2:49 AM
My Badges

Hi,

I'm still not clear on the functional requirement what you have, may I as for an example please? You can do the datasource binding from code, but still not sure why it would be necessary?

Reply
Martin Dráb responded on 12 Oct 2018 3:00 AM

Where do you want to store the data if not in database? It can't magically appear in the form; you must store it somewhere. And database is the only reasonable place.

The requirement of not storing data in database looks utterly wrong. It seems to be based on wrong assumptions - that the data is stored in database doesn't mean that it must be duplicated. That just means that the person had a wrong data model in mind and the solution is using a better data model.

How data should be stored isn't a functional requirement in the first place; it's not related to business functions. It's merely somebody's idea about how the application should be implemented and the person doesn't seem to be a software architect.

Reply
István Orosz responded on 11 Oct 2018 8:25 AM
My Badges
Suggested Answer

Hi,

Do you mean, that the DataSource and the DataField properties are not set for the stringEdit? In this case the grid does not know which table and field should be connected to the stringEdit value.

Reply
Martin Dráb responded on 11 Oct 2018 8:56 AM
Suggested Answer

The best solution is binding the control to a datasource field. If you can't do that for some reason, you'll have to save it somewhere in your own code. But because you'll have to save to a database anyway, using a datasource instead of custom code is likely a better option.

Reply
Suggested Answer

In general if you need to store a piece of information in AX, you use a database table and field for that.

If you want to show this data in a form, you use that table as a data source for the form, and create a control that is bound to the field in the data source.

Could you explain why you don't want to use this approach? What is your functional requirement?

Reply
Suggested Answer

I still don't understand. If this StringEdit repeats for the number of records, I would say you just need to add one new field to your form data source that represents these records. And bound that field in the StringEdit control.

Or if you want, you can create a new table that is related to the current data source table.

What information is in this string field? And what are the records that are related to it?

If you don't want to store that information in the database, then where? The sole purpose of database is to store data. 

Reply

SBX - Two Col Forum

SBX - Migrated JS