protected override OrganizationRequest SetupTriggerRequest() { Entity template = TemplatesHelper.RetrieveTemplateByName(templateName, this.OrganizationService); if (!template.Contains("title")) { Assert.Fail("Template doesn't contain a title"); } rowEmailSubject = template["title"].ToString(); Entity contact = CreateContact(); payment = CreatePayment(contact); EntityReference paymentReference = payment.ToEntityReference(); WhoAmIResponse whoAmI = OrganizationService.Execute(new WhoAmIRequest()) as WhoAmIResponse; Entity whoAmIUser = new Entity("systemuser"); whoAmIUser.Id = whoAmI.UserId; EntityCollection to = new EntityCollection(); to.Entities.Add(contact); return(new dxtools_SendCustomEmailRequest() { EmailTemplateName = template["title"].ToString() , ToRecipient = to , FromSender = new EntityReference("systemuser", whoAmI.UserId) , Regarding = paymentReference , RecordContext = paymentReference , Attachments = string.Empty , StaticParameters = "{\"currentvat\":\"20%\"}" }); }
public void RetrieveExistingTemplate() { Entity template = TemplatesHelper.RetrieveTemplateByName(TemplateName, this.CrmOrganisationService); Assert.IsTrue(template.Contains("presentationxml")); InstantiateTemplateRequest instantiateTemplateRequest = new InstantiateTemplateRequest() { ObjectId = Systemuser.GetCallingUserID(this.CrmOrganisationService) , ObjectType = "systemuser" , TemplateId = template.Id }; InstantiateTemplateResponse instantiateTemplateResponse = this.CrmOrganisationService.Execute(instantiateTemplateRequest) as InstantiateTemplateResponse; Assert.IsNotNull(instantiateTemplateResponse.EntityCollection.Entities[0]); Entity email = instantiateTemplateResponse.EntityCollection.Entities[0]; Assert.IsTrue(email.Contains("description")); }
public void TestCreateTemplateProgramatically() { string templateName = "DXTools - Test Create Template Programatically " + DateTime.Now; string subject = "DXTools Template created Programatically " + DateTime.Now; string body = "<p><strong>Amazing</strong></p>"; Entity newTemplate = BuildTemplate(templateName, subject, body); //Validate Template has been created correctly Entity existingTemplateRecord = TemplatesHelper.RetrieveTemplateByName(templateName, this.CrmOrganisationService); Assert.IsNotNull(existingTemplateRecord); Assert.IsTrue(existingTemplateRecord["subject"].ToString().Contains(subject)); Assert.IsTrue(existingTemplateRecord["body"].ToString().Contains(body)); //Validate email based on template is correct Entity emailRecord = GetEmailInstantiateFromTemplate(newTemplate, GetCurrentUser().Id); Assert.IsTrue(emailRecord["subject"].ToString().Contains(subject)); Assert.IsTrue(emailRecord["description"].ToString().Contains(body)); //Email body //Validate email can be created in CRM succesfully this.CrmOrganisationService.Create(emailRecord); }
public void RetrieveExistingTemplate() { Entity template = TemplatesHelper.RetrieveTemplateByName(TemplateName, this.CrmOrganisationService); Assert.IsTrue(template.Contains("presentationxml")); }