4, CRM2011 programming Combat--the value of the specified control in the form is processed and updated to another field

Source: Internet
Author: User
Tags microsoft dynamics

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.


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.