Hello!
I am currently working with a customer that wants to use the standard Dataverse integration to sync accounts and contacts between BC and Dataverse. During this work I have encountered a little bit of a problem, and I need some help to resolve it.
The issue I have is regarding the sync of the Blocked field from BC to Dataverse. Of course the customer is using a custom field in Dataverse, and it has the following values:
In BC they are using the standard field, so the values are
value(0; " ") { Caption = ' '; }
value(1; "Ship") { Caption = 'Ship'; }
value(2; "Invoice") { Caption = 'Invoice'; }
value(3; "All") { Caption = 'All'; }
I have managed to get this sync to go all ways with a custom transformation rule that looks like this:
[EventSubscriber(ObjectType::Table, Database::"Transformation Rule", 'OnTransformation', '', false, false)]
local procedure OnTransformation(TransformationCode: Code[20]; InputText: Text; var OutputText: Text)
var
Normalized: Text;
BlockedEnum: Enum "Customer Blocked";
begin
if TransformationCode <> 'BLOCKED_STATUS' then
exit;
Normalized := InputText.Trim();
case Normalized of
// BC -> Dataverse
Format(BlockedEnum::Ship):
OutputText := '168500000';
Format(BlockedEnum::Invoice):
OutputText := '168500001';
Format(BlockedEnum::All):
OutputText := '168500002';
// Dataverse -> BC
'':
OutputText := Format(BlockedEnum::" ");
'168500000':
OutputText := Format(BlockedEnum::Ship);
'168500001':
OutputText := Format(BlockedEnum::Invoice);
'168500002':
OutputText := Format(BlockedEnum::All);
else
OutputText := InputText;
end;
end;
This works perfectly for all values, apart from when the value is " " in BC. I think the problem is that when it is " " in BC, I need it to just clear the value in Dataverse, because that's how it is used in the current solution, since there are only three options in the Dataverse option. For all the other enum values in BC, it translates to the correct value in Dataverse, and it is the same for the other direction, even when it is blank in Dataverse, it sets the " " value in BC.
I feel like I have tried all kinds of things, but always get one of the two errors:
- If I add an extra case for the BC -> Dataverse, looking similar to: Case - BlockedEnum::" " => OutputText := ''; Then I get an error saying "The type NavOption is unknown".
- If I try to do something similar, but replace '' with '1' for example, I get an error saying the value 1 is outside of the expected range, and that it expects one of the three 168500000 values.
- If I replace '' with '168500000' it works well, but of course I get the wrong value in Dataverse, because it should be clear, ie not containing a value in Dataverse.
- Adding Clear(OutputText) gives the same NavOption error
- I tried adding an event subscriber that listened to the OnTransferFieldData of the Integration Record Sync codeunit, but that didn't seem to help me either, and it seems like I can't debug it.
- I could also remove the else clause where I set the OutputText = InputText, but then there will not be any update if the field is blank in Dataverse either way.
The easiest thing to do would probably be to add an option that is empty but has a value in Dataverse, but my company and I are not responsible for their Dataverse solution, so I would have to ask another consultant. I would still like to learn if this is something that can be solved, so if anyone have encountered a similar case and have found a way around it, I would greatly appreciate it!