title: CRM Dynamics How to get the current user view url in c# code
body: <p>I have a scenario in CRM where I have a MVC application that connect to CRM and user uploads an excel file with data, that data gets validated against a proc the validated results(records) are then created in CRM using the MVC Application. After the records are created I then send an email to the logged in user's manager ,this email needs to contain a URL/Link to the view where the records have just been created, which is My Active Supplier Claims Update in my instance, How do I query CRM to get the View URL for that logged in user just before I send the email. Please see my code below as to how far I got, I am a bit stuck with this step. </p>
  
  <pre><code>public ActionResult ImportDataToCRM(CRM_Embrace_IntegrationEntities1 db)
      {
  
          int sessionIdentifier = (int)Session["sessionID"];
  
          var claimsRecords = db.GPClaimsReadyToImports.Where(x =&gt; x.CleanSupplierClaimSessionID == sessionIdentifier).ToList();
  
          CrmConnection conn = new CrmConnection("CRM");
          var service = new OrganizationService(conn);
          OrganizationServiceProxy proxy;// = new OrganizationServiceProxy;
          WhoAmIRequest whoReq = new WhoAmIRequest();
          WhoAmIResponse whoResp = (WhoAmIResponse)service.Execute(whoReq);
          Guid userid = whoResp.UserId;
  
          proxy = service.InnerService as OrganizationServiceProxy;
          proxy.CallerId = whoResp.UserId;
  
          conn.CallerId = userid;
  
          var cleanClaimsFromDB = claimsRecords; 
  
          foreach (var claim in cleanClaimsFromDB)
          {
              new_supplierclaimsupdate CRMSupplierClaimsData = new new_supplierclaimsupdate()
              {
                  new_Action = claim.Action.Trim(),
                  new_InvoiceNumebr = claim.Line_Number.Trim(),
                  new_Warning = claim.Warning.Trim(),
                  new_TotalClaim = Convert.ToDecimal(claim.Total_Claim).ToString(),
                  new_Currency = claim.Currency.Trim(),
                  new_Supplier = claim.Claim_Reference.Trim(),
                  OwnerId = new EntityReference(SystemUser.EntityLogicalName, userid),
              };
  
              Guid _supplierClaimID = service.Create(CRMSupplierClaimsData);
  
              TempData["supplierClaimID"] = _supplierClaimID;
  
          }
  
          Guid supplierClaimsRecordId = Guid.Parse(TempData["supplierClaimID"].ToString());
  
          Email email = new Email();
  
          ActivityParty from = new ActivityParty();
          email.OwnerId = from.PartyId = new EntityReference("systemuser", Guid.Parse("B8CB8298-43F4-E211-A707-D067E5EBE694"));
  
          ActivityParty to = new ActivityParty();
          to.PartyId = new EntityReference("systemuser", Guid.Parse("C4354817-147E-E511-80D4-00155D060AC7")); 
  
  
          email.From = new ActivityParty[] { from };
          email.DirectionCode = true;
          email.To = new ActivityParty[] { to };
          email.Subcategory = "Manager To Review Claims Updated  By User";
          email.Description = //The URL VIEW WILL BE ADDED HERE.
          email.RegardingObjectId = new EntityReference("new_supplierclaimsupdate", supplierClaimsRecordId);
          service.Create(email);
  
  
  
          return View("ImportReadyClaims", cleanClaimsFromDB);
      }
  </code></pre>
  
  <p>How can I do this in C# Code. I know of an OOTB way in CRM but that is using an On-Demand workflow and that is not part of the requirement, as this needs to be automated. I would really appreciate your help.</p>