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 CRM (Archived)

How to handle null records

(0) ShareShare
ReportReport
Posted on by 2,665

Hi,

I am writing a custom data import process that imports data from a .csv to CRM.

There are values(child entity) related to the main entity which can be empty or blank. Since I am not checking for any condition and using service.create to create the child entity and associating it to parent entity, it is creating blank child records. In reality, those blank child records should not exist. How do I put condition before creating child record? There are many fields that I need to check for null values in order to prevent blank records. How does it affect checking for null values for so many fields in a 'If' condition?

Or else, can I delete those blank records through some workflow or plugin as they get created through data import process?

Someone please guide me through this.

Thanks for any help.

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Royal King Profile Picture
    27,686 on at

    You can go with either restricting creation of record by checking null values or deleting it after creating it in the crm using workflow or bulk delete. You have to test which method performs well. Choose the one that provides better performance.

  • Verified answer
    Mahendar Pal Profile Picture
    45,095 on at

    Hi,

    Well you have both the options if you want to modify the code you can write validation to only create record in case specific attributes having value, it will give you more control if you want to implement any other validation as well. It will also avoid doing any extra work.

    Otherwise you can simply design bulk deletion job where you can define your record send and let it delete blank records for you.

    Thanks

  • crmprogrammer2013 Profile Picture
    2,665 on at

    Thanks guys.

  • Aileen Gusni Profile Picture
    44,524 on at

    Hi Roxanna

    I would prefer do checking first.

    Rather than later delete it.

    Since checking you just do validation then create the record meanwhile if you create then delete you will need to call 2 times service request to service.create and service.delete as well.

    Put a plugin in the child record then throw exception or put the validation in the parent to not create thr child record if your source at first is by cresting the parent then inside the code creating child.

    Hope this helps you.

    Thanks.

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 CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans