الأحد، 26 مايو 2013
السبت، 25 مايو 2013
الثلاثاء، 14 مايو 2013
CRM 2011: Javascript Xrm.Page Basics
//***** Get the value from a CRM field
var varMyValue = Xrm.Page.getAttribute(“CRMFieldSchemaName”).getValue() ;
//****** Set the value of a CRM field
Xrm.Page.getAttribute(“po_CRMFieldSchemaName”).setValue(‘My New Value’);
//***** Hide/Show a tab/section
Xrm.Page.ui.tabs.get("Tab Name").setVisible(false);
Xrm.Page.ui.tabs.get("Tab Name").sections.get("Section Name").setVisible(true);
//*****Call the onchange event of a field
Xrm.Page.getAttribute(“CRMFieldSchemaName”).fireOnChange();
//****Get the selected value of picklist
Xrm.Page.getAttribute(“CRMFieldSchemaName”).getSelectedOption().text;
//******Set the requirement level
Xrm.Page.getAttribute(“CRMFieldSchemaName”).setRequiredLevel(“none”);
Xrm.Page.getAttribute(“CRMFieldSchemaName”).setRequiredLevel(“required”);
Xrm.Page.getAttribute(“CRMFieldSchemaName”).setRequiredLevel(“recommended”);
//********Set the focus to a field
Xrm.Page.getControl(“CRMFieldSchemaName”).setFocus(true);
//***********Stop an on save event
event.returnValue = false;
//**** Return array of strings of users security role GUIDs:
Xrm.Page.context.getUserRoles()
Method returns a Boolean value that indicates if any fields in the form have been modified.
Xrm.Page.data.entity.getIsDirty()
CRM 2011 : Value cannot be null. Parameter name: localContext
This error appear when was a problem in custom plugins so that unregister this plugin.
السبت، 11 مايو 2013
CRM 2011:An error has occurred. Try this action again. If the problem continues, check the Microsoft Dynamics CRM Community for solutions or contact your organization's Microsoft Dynamics CRM Administrator. Finally, you can contact Microsoft Support.
To Solve this error do the following:
1- Stop and start CRMAppPool
2- stop and restart Microsoft Dynamics CRM Site
OR change the user that running the CRmAppPool
الأربعاء، 1 مايو 2013
Send Email Attachment Using Stream
we need to send email with attachment and we didn't need to save this file to computer first and take the path
of file in function of send email.
to solve this issue:
1-
public void SendHtmlMail(string To, string Subject, string Body, string AttachFile, byte[] FileStream)
{
string SMTPServe = "smtp.gmail.com";
string From = "email@gmail.com";
string fromPassword = "password";
int Port = "587";
// smtp settings
MailMessage message = new MailMessage(From, To, Subject, Body);
message.IsBodyHtml = true;
Stream ContentStream = new MemoryStream(FileStream);
if (!string.IsNullOrEmpty(AttachFile))
{
System.Net.Mail.Attachment attachment = new System.Net.Mail.Attachment(ContentStream, Path.GetFileName(AttachFile));
message.Attachments.Add(attachment);
}
var smtp = new System.Net.Mail.SmtpClient();
{
smtp.Host = SMTPServe;
smtp.Port = Port;
smtp.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
smtp.Credentials = new NetworkCredential(From, fromPassword);
smtp.Timeout = 80000;
}
try
{
smtp.Send(message);
//return "Your Email has been sent";
}
catch(Exception ex)
{
throw new Exception(ex.Message);
//return ex.Message;
}
}
}
2-
public static byte[] ConvertStreamToByte(Stream input)
{
byte[] buffer = new byte[input.Length];
//byte[] buffer = new byte[16 * 1024];
using (MemoryStream ms = new MemoryStream())
{
int read;
while ((read = input.Read(buffer, 0, buffer.Length)) > 0)
{
ms.Write(buffer, 0, read);
}
return ms.ToArray();
}
}
3-
byte[] byteArr = ConvertStreamToByte(FileUpload1.PostedFile.InputStream);
SendHtmlMail(ToEmail, Subject, Body, FileUpload1.FileName, byteArr);
الاشتراك في:
الرسائل (Atom)