private string GetProductUrl(Entity product) { if (product == null || product.GetAttributeValue <EntityReference>("subjectid") == null) { return(null); } var productPage = XrmContext.CreateQuery("adx_webpage") .FirstOrDefault(e => e.GetAttributeValue <EntityReference>("adx_subjectid") == product.GetAttributeValue <EntityReference>("subjectid") && e.GetAttributeValue <EntityReference>("adx_websiteid") == Website.ToEntityReference()); return(productPage == null ? null : XrmContext.GetUrl(productPage)); }
protected void AddAlert_Click(object sender, EventArgs e) { if (!Request.IsAuthenticated) { return; } var user = Portal.User; if (user == null) { return; } var dataAdapter = CreateAlertDataAdapter(); var url = XrmContext.GetUrl(Entity); var id = ServiceRequest.GetAttributeValue <EntityReference>("adx_servicerequest").Id.ToString(); dataAdapter.CreateAlert(user.ToEntityReference(), url, id); Response.Redirect(Request.Url.PathAndQuery); }