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

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

AIF Document Services... Setting Default Values?

(0) ShareShare
ReportReport
Posted on by 2

Hello,

When writing to AX using Document Services, does any know where the best place is to add logic to default field values.

I'm not sure whether this logic should be added to the Axd Document Class or to the parameter methods of the data object classes?

Can anyone offer any advice?

Thanks in advance,

Nick

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    640579632b5c4e6780a624c4771b6f93 Profile Picture
    4,730 on at
    Re: AIF Document Services... Setting Default Values?

    Depends if the defaults are regardless of where the document is created from like client , AIF or EP then the best place is to add on the defaultField method of the table.

    See AdvanceLedgerEntry webservice for public sector (fpk layer).

    If you want to defualt the values only when used with web service then I would add the logic to prepareForsave.

  • NR-11010513-0 Profile Picture
    2 on at
    Re: AIF Document Services... Setting Default Values?

    Thanks for your response.

    The defaults would be for the web service only, so I will try setting the values in the prepareForSave method.

    Cheers.

  • NR-11010513-0 Profile Picture
    2 on at
    Re: AIF Document Services... Setting Default Values?

    I've attempted to add the logic to set the default values in the prepareForSaveExtended() method, but this doesn't seem to work. Maybe I am setting it in the wrong place? Below is an example of where I have tried to default the value of an the organization's name.

            // ----------------------------------------------------------------------

            // Process Organization records

            // ----------------------------------------------------------------------

            case #Organization_DataSourceName:

     

                axbc_Organization_DirOrganization = _axBcStack.top();

                //TODO Put validating code for DirOrganization here

     

                //Default value of Organization Name

                axbc_Organization_DirOrganization.parmName("NameSetByService");

     

                switch (_recordProcessingContext)

                {

                    // Ensure Organization record is saved before any of its dependent child records

                    case AxdRecordProcessingContext::BeforeChildRecordProcessed:

                        switch (_childRecord.dataSourceName())

                        {

                            case #PartyLocation_DataSourceName:

                                if (!axbc_Organization_DirOrganization.isProcessed())

                                {

                                    return true;

                                }

                                break;

                        }

     

                        return false;

     

                    // Ensure Organization record is saved

                    case AxdRecordProcessingContext::AfterAllChildRecordsProcessed:

                        if (!axbc_Organization_DirOrganization.isProcessed())

                        {

                            return true;

                        }

     

                        return false;

                }

     

                return false;

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
Priya_K Profile Picture

Priya_K 4

#2
Alexey Lekanov Profile Picture

Alexey Lekanov 3

#3
Scott_itD Profile Picture

Scott_itD 2 Community Manager

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans