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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Unanswered

comparing strings

(0) ShareShare
ReportReport
Posted on by 146
Hi,
 
in some cases,

ElectronicAddressRoles orignal  contains: Home;Delivery
and new one contains Delivery;Home

for me there is no difference so i don't want to enter the if condition
 public void update()
 {
     LogisticsElectronicAddress  original = this.orig();


     next update();

    if(this.ElectronicAddressRoles != original.ElectronicAddressRoles)
    {
         //do sth
    }
}

The thing is update method gets called sometimes more than once

so let's say purpose was originally home
i edited it to be Delivery;Business
 
first time the "update" method is called, it will see it was Delivery and it became Delivery;Business, so it enters if condition

but update gets called again
where old will appear now as Delivery;Business as it already changed. And the new one will also have same value but in different order Business;Delivery  (it gets reordered somehow alphabatically)

this causes the if condition to enter twice and i don't want that

how to handle compare properly?

but if first value was Business, then we added delivery, then no issue because B letter comes before D letter
Categories:
I have the same question (0)
  • Diego Mancassola Profile Picture
    276 on at

    Hello, suggest you to not compare ElectronicAddressRoles as a string at all.

    That field is only a derived representation. The real source of truth is in the tables.
    You can read the table logisticsElectronicAddressRole

    Example:

    while select logisticsLocationRole
    order by logisticsLocationRole.Name asc
    exists join logisticsElectronicAddressRole
    where logisticsElectronicAddressRole.LocationRole == logisticsLocationRole.RecId
    && logisticsElectronicAddressRole.ElectronicAddress == _electronicAddressRecId
    {
    }
     
    This is more robust than comparing the string value.
     
    Standard order the rapresentation by name
    What do you to inside you condition?

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…

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 584 Super User 2025 Season 2

#2
Abhilash Warrier Profile Picture

Abhilash Warrier 428 Super User 2025 Season 2

#3
Martin Dráb Profile Picture

Martin Dráb 331 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans