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)

Delete field - value(record) from table with X++

(0) ShareShare
ReportReport
Posted on by 159

Hi everyone,

I want to delete one record in custom table with name ImportSalesPRiceParameters and filed Journalname.

This is my classDeclaration:

public class Test
{
 ImportSalesPRiceParameters    ispp;
       
}

Here is get method:

[
    SRSReportDataSetAttribute(tableStr(ImportSalesPRiceParameters))
]
public ImportSalesPRiceParameters getISPP()
{
    select ispp;
    return ispp;
}

Delete method:

public void deleteFromISPP()
{
    select pda where ispp.JournalName == 'SalesCRM' && ispp.dataAreaId == '110';
    ispp.delete();
    
}

This is field in SQL:
0250.s1.JPG

In other languages like C# I can write 

if(ImportSalesPRiceParameters.Any())

{

//delete record or make it null value;

}

I want Journalname to assigned null value.How to make it with X++

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Amir Nazim Profile Picture
    5,994 on at

    you can select the record for update using selectForUpdate(true)

    set ispp.JournalName = "";

    then call ispp.update();

    Please check

    docs.microsoft.com/.../xpp-data-query

  • Suggested answer
    Pradeep_Prakash Profile Picture
    717 on at

    HI,

    You have selected pda its should be

    select ispp where ispp.JournalName == 'SalesCRM' && ispp.dataAreaId == '110';

       ispp.delete();

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

    Vladislav, please separate tags with comma and don't prefix them with #. You attached a single tag #sql #ax2012R3 #delete instead of three tags.

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

    Assing NULL to a field is a completely different thing than deleting a record.

    Your code is almost correct, you just select from a wrong variable and you need a few more pieces.

    Try this:

    ttsBegin;

    select forUpdate issp where ispp.JournalName == 'SalesCRM' && ispp.dataAreaId == '110'; if (ispp) { ispp.delete(); }

    ttsCommit;

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