insert new record using X++

Hello,

I added a new tab in CustParameters from, the added tab contains a grid.
y problem I can not create new records in this grid may be the reason is that the form "new" toolbar is disabled.

Can I add the record using X++? please paste the code.
smetechitAsked:
Who is Participating?
 
agusacilConnect With a Mentor Commented:
Hi,

Parameter form normally have only single record. Do you add new table or add new fields to the CustParameter table?
If you add a new table then you need to set Grid's data source property to the data source of your new table to allow creating new record.

Add record through X++ (copied from dev help ):
CustTable custTable;
;
ttsBegin;
  
select forUpdate custTable;
custTable.AccountNum = '5000';
custTable.Name = 'MyCompany';
custTable.insert();
  
ttsCommit;

Open in new window

0
 
agusacilCommented:
Hi,

Thanks. I am not sure which one eventually you did. For additional note, the code above assuming some fields value are defaulted from existing record. To get a clean new record you should do this :

CustTable custTable;
;
ttsBegin;
  
custTable.clear()
custTable.AccountNum = '5000';
custTable.Name = 'MyCompany';
// Assign other fields here, especially mandatory fields.
custTable.insert();

Open in new window

 
ttsCommit;
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.