public override object BeforeMethod(string method) { if (method == null) { return(null); } if (string.Equals(method, "logicalname", StringComparison.OrdinalIgnoreCase)) { return(LogicalName); } Guid id; if (!Guid.TryParse(method, out id)) { return(null); } using (var serviceContext = PortalViewContext.CreateServiceContext()) { try { var entity = serviceContext.RetrieveSingle(new EntityReference(this.LogicalName, id), new ColumnSet(true)); EntityDrop entityDrop = (entity == null) ? null : new EntityDrop(this, entity); return((entityDrop != null && entityDrop.Permissions.CanRead) ? entityDrop : null); } catch (FaultException <OrganizationServiceFault> ) { return(null); } } }
private EntityDrop CreateEntityDropWithPermission(Entity entity) { if (entity == null) { return(null); } EntityDrop entityDrop = new EntityDrop(this, entity, _languageCode, _view); return(entityDrop.Permissions.CanRead ? entityDrop : null); }
/// <summary> /// Format a given numeric value according to the CRM currency settings for a given record and /// entity attribute. /// </summary> public static string Currency(Context context, object value, EntityDrop record, string attribute, string format = null) { if (record == null || attribute == null) { return(null); } IPortalLiquidContext portalLiquidContext; if (!context.TryGetPortalLiquidContext(out portalLiquidContext)) { return(null); } var moneyAttributeMetadata = record.EntityMetadata.Attributes .FirstOrDefault(e => string.Equals(e.LogicalName, attribute, StringComparison.OrdinalIgnoreCase)) as MoneyAttributeMetadata; if (moneyAttributeMetadata == null) { return(null); } return(FormatCurrency(value, format, new MoneyFormatter(portalLiquidContext.OrganizationMoneyFormatInfo, record.MoneyFormatInfo, moneyAttributeMetadata))); }