Skip to main content

Notifications

Finance | Project Operations, Human Resources, ...
Suggested answer

Validate the Multiselect field value before importing to entity table.

(0) ShareShare
ReportReport
Posted on by 100

Hi Experts,

I want to validate and import the multi select field data in Sales Order Line V2 Entity.

The file is importing successfully but the data in my Multiselect Field(ManufacturingPlant_CAP) is not updating.

can anyone help out here.

 

[Extensionof(tableStr(SalesOrderLineV2Entity))]
internal final class SalesLineManufacturingPlantImp_CAP_Extension
{
    public static void postTargetProcess(DMFDefinitionGroupExecution _dmfDefinitionGroupExecution)
    {
        SalesLine   salesline;
        InventSite inventSite;
        container   tmpValues,chk;
        int         idx;
        //check if import job is finished
        if (_dmfDefinitionGroupExecution.StagingStatus == DMFBatchJobStatus::Finished)
        {
            SalesOrderLineV2Staging salesOrderLineV2Staging;
            ttsbegin;
            while select salesOrderLineV2Staging
            where salesOrderLineV2Staging.DefinitionGroup == _dmfDefinitionGroupExecution.DefinitionGroup
               && salesOrderLineV2Staging.ExecutionId     == _dmfDefinitionGroupExecution.ExecutionId
               && salesOrderLineV2Staging.TransferStatus  == DMFTransferStatus::Completed
            {
                if (salesOrderLineV2Staging.SalesOrderNumber != '')
                {
                    tmpValues = str2con(salesOrderLineV2Staging.ManufacturingPlant_CAP, ';');
     
                    for (idx = 1; idx <= conLen(tmpValues); idx  )
                    {
                        inventSite = InventSite::find(conPeek(tmpValues, idx));
                         if (! inventSite.RecId)
                         {
                           error(strFmt("Value '%1' in Manufacturing Plant Field is not valid", conPeek(tmpValues, idx)));
                        }
                    }
                    salesline.ManufacturingPlant_CAP = salesOrderLineV2Staging.ManufacturingPlant_CAP;
                    salesline.update();
               ttscommit;
                }
            }
        }
        next postTargetProcess(_dmfDefinitionGroupExecution);
    }

}

  • Suggested answer
    Mohit Rampal Profile Picture
    Mohit Rampal 12,552 Super User 2024 Season 1 on at
    RE: Validate the Multiselect field value before importing to entity table.

    For field missing in exported file, please generate mapping for the data entity and add it in project again and try.

    For salesLine null, try removing call to next in postTargetProcess method

    www.songnghia.com/.../d365-fo-method-calling-sequence-of-data.html

  • HARISH MEHRA Profile Picture
    HARISH MEHRA 100 on at
    RE: Validate the Multiselect field value before importing to entity table.

    Yes ,debug postTargetProcess method and in salesOrderLineV2Staging table I am getting the field(ManufacturingPlant_CAP) data but in salesline variable it is showing null for all fields.

    One more thing - When I am Exporting the Entity .My added fields are  missing in that exported file.

    NOTE - I have added my fields in both Entity as well as in Staging table.

  • Suggested answer
    Mohit Rampal Profile Picture
    Mohit Rampal 12,552 Super User 2024 Season 1 on at
    RE: Validate the Multiselect field value before importing to entity table.

    Have you debugged postTargetProcess method? Is salesLine update method is called with correct value.

    Also, you might want to re-check the placement of code. If you want to validate that the string values have a valid site in system then probably use ValidateWrite method and instead of postTargetProcess method, use mapEntityToDatasource.

    learn.microsoft.com/.../validations-defaults-unmapped-fields

    Hope you already know that postTargetProcess method is not called via OData (consider for future work).

  • HARISH MEHRA Profile Picture
    HARISH MEHRA 100 on at
    RE: Validate the Multiselect field value before importing to entity table.

    6862.Capture3.PNG

    Hello Rampal,

    Added the line but result is same. Actually in staging table it is showing the correct updated data which I have entered in excel sheet. But When I an checking in SalesLine table it is not updating.

    Thanks

  • Suggested answer
    Mohit Rampal Profile Picture
    Mohit Rampal 12,552 Super User 2024 Season 1 on at
    RE: Validate the Multiselect field value before importing to entity table.

    Hi Harish, Are you getting anything in SalesLine table buffer. If not then try adding below code at Line# 32

    salesline = SalesLine::find(salesOrderLineV2Staging.SalesOrderNumber, salesOrderLineV2Staging.LineNum, true);

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,965 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,836 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans