I have model like this. A CLIENT has a related data called FORMATION which based on Product. I need to add this FORMATION to related data field in CLIENT by code (not on GUI in back-end). So here the code i have done.
Guid id = new Guid();
bool tryParse = Guid.TryParse(FormationId, out id);
DynamicModuleManager dynamicModuleManager = DynamicModuleManager.GetManager();
Type clientType = TypeResolutionService.ResolveType(CpModuleClrType.Client);
DynamicContent clientItem = dynamicModuleManager.GetDataItems(clientType).Where(c => c.GetValue<string>(ClientField.Nom) == "name").First();
// This is how values for the properties are set
// Gets error by this line
clientItem.SetValue(ClientField.Favoris, new List<Guid> id );
// We can now call the following to publish the item
ILifecycleDataItem publishedArtistsItem = dynamicModuleManager.Lifecycle.Publish(clientItem);
//You need to set appropriate workflow status
// You need to call SaveChanges() in order for the items to be actually persisted to data store
The Guid id is the id of a particular formation. When i run this, it keeps getting error "Object must implement IConvertible."
I have tried another way fix this by replacing SetValue by CreateRelation. There was no Error but it didn't save the formation.
How could i change this code to make it works?