Пример #1
0
 public virtual Entity UpdateFieldsAndRetreive(XrmService xrmService, Entity entity, params string[] fieldsToUpdate)
 {
     if (xrmService == null)
     {
         xrmService = XrmService;
     }
     xrmService.Update(entity, fieldsToUpdate);
     return(xrmService.Retrieve(entity.LogicalName, entity.Id));
 }
Пример #2
0
 /// <summary>
 ///     FIELD MUST BE IN PREIMAGE! Returns the effective value of the field in the context record (gets from the target
 ///     entity or if not in gets from the preimage)
 /// </summary>
 public IEnumerable <Entity> GetActivityParties(string fieldName)
 {
     if (TargetEntity.Contains(fieldName))
     {
         return(TargetEntity.GetActivityParties(fieldName));
     }
     else if (!IsMessage(PluginMessage.Create))
     {
         var lookThisUp = XrmService.Retrieve(TargetType, TargetId, new[] { fieldName });
         PreImageEntity.SetField(fieldName, lookThisUp.GetField(fieldName));
         return(PreImageEntity.GetActivityParties(fieldName));
     }
     return(new Entity[0]);
 }
Пример #3
0
        public virtual Entity CreateAndRetrieve(Entity entity, XrmService xrmService = null)
        {
            if (xrmService == null)
            {
                xrmService = XrmService;
            }
            var primaryField = xrmService.GetPrimaryField(entity.LogicalName);

            if (!entity.Contains(primaryField))
            {
                entity.SetField(primaryField, ("Test Scripted Record" + DateTime.UtcNow.ToFileTime()).Left(xrmService.GetMaxLength(primaryField, entity.LogicalName)));
            }
            if (entity.LogicalName == Entities.contact && !entity.Contains(Fields.contact_.firstname))
            {
                entity.SetField(Fields.contact_.firstname, "Test");
            }
            if (entity.LogicalName == Entities.lead && !entity.Contains(Fields.lead_.firstname))
            {
                entity.SetField(Fields.lead_.firstname, "Test");
            }
            var id = xrmService.Create(entity);

            return(xrmService.Retrieve(entity.LogicalName, id));
        }
Пример #4
0
 public Entity UpdateFieldsAndRetreive(Entity entity, IEnumerable <string> fieldsToUpdate)
 {
     XrmService.Update(entity, fieldsToUpdate);
     return(XrmService.Retrieve(entity.LogicalName, entity.Id));
 }
Пример #5
0
 public Entity Refresh(Entity entity)
 {
     return(XrmService.Retrieve(entity.LogicalName, entity.Id));
 }