Hello RudyZhang,
thank you very much for testing.
Please find below our Power Automate steps:
Value Set Contact = concat('contacts(', triggerOutputs()?['body/_emailsender_value'], ')')
Value Set Account as Customer = if(equals(outputs('Retrieve_sender_contact')?['body/_parentcustomerid_value@Microsoft.Dynamics.CRM.lookuplogicalname'],'account'),concat('accounts(',outputs('Retrieve_sender_contact')?['body/_parentcustomerid_value'],')'),outputs('Retrieve_sender_contact')?['body/@odata.id'])
Value Set parent customer of sender as customer = concat('accounts(',triggerOutputs()?['body/_emailsender_value'], ')')
Customer (Accounts) = if(startsWith(variables('Customer from email sender'),'accounts'),variables('Customer from email sender'),string(''))
Customer (Contacts) = if(contains(variables('Customer from email sender'),'contacts'),variables('Customer from email sender'),string(''))
Primary Contact (Contacts) = if(contains(variables('Customer from email sender'),triggerOutputs()?['body/_emailsender_value']),string(''),concat('contacts(',triggerOutputs()?['body/_emailsender_value'], ')'))