Requirements: updated to the field "expiry deadline" by adding the value of the receipt time plus the expiration reminder time
Js Call:
Set expiration deadline function Setdeadline () { var recordId = Xrm.Page.data.entity.getId (); var entityname = Xrm.Page.data.entity.getEntityName (); var reportedtime = Xrm.Page.getControl ("Hxcs_fdatetimeofrequesthelp"). getattribute (). GetValue (). tolocalestring (); var remindtime =xrm.page.getcontrol ("Hxcs_fremindtime"). getattribute (). GetText (); $.post ("/isv/handlers/setremindhandler.ashx", {"recordId": RecordId, "EntityName": EntityName, "Reportedtime": Reportedtime, "Remindtime": Remindtime}, function (data) {});
Generic handler setremindhandler.ashx The code is as follows:
Using system;using system.collections.generic;using system.linq;using system.web;using Microsoft.Xrm.Sdk;using Microsoft.xrm.sdk.client;using system.net;using system.servicemodel.description;using System.Configuration; namespace iswaterweb{//<summary>///Setremindhandler///</summary> public class Setremi Ndhandler:ihttphandler {Iorganizationservice _service = null; public void ProcessRequest (HttpContext context) {context. Response.ContentType = "Text/plain"; String Recordid=context. request["RecordId"]; String Entityname=context. request["EntityName"]; String reportedtime = context. request["Reportedtime"]; Time to receive the report string remindtime = context. request["Remindtime"]; Expiry reminder Time (h) if (!string. IsNullOrEmpty (Reportedtime) &&!string. IsNullOrEmpty (Remindtime)) {DateTime rtime = Convert.todatetime (reportedtime); Double HourcouNTS = Convert.todouble (remindtime); DateTime deadline = rtime.addhours (hourcounts); _service = Getorganization (); Entity entity = new entity (); Entity. Id=guid.parse (RECORDID); Entity. Logicalname=entityname; Entity. attributes["Hxcs_fdeadline"] = deadline; _service. Update (entity); }} public Iorganizationservice getorganization () {String UserName = ConfigurationManager . appsettings["LoginName"]; String Password = configurationmanager.appsettings["Loginpwd"]; String url=configurationmanager.appsettings["Organizationserviceurl"]; Uri uri = new uri (URL); var cred = new ClientCredentials (); Cred. windows.clientcredential = new NetworkCredential ("Xiaozhou", "Zhou123."); Cred. windows.clientcredential = new NetworkCredential (UserName, Password); Organizationserviceproxy _pRoxy = new Organizationserviceproxy (URI, NULL, cred, NULL); Iorganizationservice _service = (iorganizationservice) _proxy; return _service; } public bool IsReusable {get {return false; } } }}
Note: Remember to place the generic handler setremindhandler.ashx in the server directory:C:\Program Files\Microsoft Dynamics Crm\crmweb\isv \handlers, if there is no handlers directory, you can create a new.