Raja Islam's Technical blog

Latest

Get All tables Schema

To find any specific field from whole database use following query.

SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE COLUMN_NAME LIKE ‘%package%’

Blackbaud Required

To make field required we use this script using UI Model

Private Sub cboEmailType_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txt_NAME.TextChanged
Dim required As Boolean = Len(txt_NAME.Text) > 0
‘Tell base class to make the textbox for email required.
MyBase.FieldIsRequired(txt_EMAILADDRESS_EMAILADDRESS) = required

End Sub

How to parse XML and Fetch data

var input1 = TheApplication().NewPropertySet();
var output1 = TheApplication().NewPropertySet();
var svc = TheApplication().GetService(“Transcode Service”);
input1.SetProperty(“ConversionMode”,”StringToEncoding”);
input1.SetProperty(“TargetEncoding”,”UTF-8″);
//this is the string XML
input1.SetValue(“<?xml version=\”1.0\” encoding=\”UTF-8\”?>” +
“<Result><SiteRoot>http://mySite.net</SiteRoot><SiteName>mySite</SiteName>” +
“<JobMatchesLink>http://mySite.net/login.asp</JobMatchesLink>” +
“<JobMatches>25</JobMatches><ONET>15-222.00</ONET><Password>admin</Password>” +
“<Username>admin</Username><SSN>999999999</SSN></Result>”);
svc.InvokeMethod(“Convert”, input1, output1);
//assign the UTF-8 converted output to the input of the XML Converter BS
var inputx = output1;
var outputx = TheApplication().NewPropertySet();
var svc = TheApplicationication().GetService(“XML Converter”);
//TheApplication().GetBusObject(“Contact”).GetBusComp(“Contact”).SetFieldValue(“lastname”,”123″);
svc.InvokeMethod(“XMLToPropSet”, inputx, outputx);
/*in the BS simulator you will see the Result with all the XML into a
property set hierarchy and you can access these child properties as I
showed you in my previous code.*/
Outputs.AddChild(outputx);
COMCreateObject(“WScript.Shell”).PopUp(outputx.GetChild(6).GetValue());

I used this code in siebel Business Service.  It will display value from XML in popup  which is “admin” because it is sixth in hierarchy.  Below is the code to get any value from XML string.

var input1 = TheApplication().NewPropertySet();

var output1 = TheApplication().NewPropertySet();

var svc = TheApplication().GetService(“Transcode Service”);

input1.SetProperty(“ConversionMode”,”StringToEncoding”);

input1.SetProperty(“TargetEncoding”,”UTF-8″);

//this is the string XML

input1.SetValue(“<?xml version=\”1.0\” encoding=\”UTF-8\”?>” +

“<Result><SiteRoot>http://mySite.net</SiteRoot><SiteName>mySite</SiteName>” +

“<JobMatchesLink>http://mySite.net/login.asp</JobMatchesLink>” +

“<JobMatches>25</JobMatches><ONET>15-222.00</ONET><Password>admin</Password>” +

“<Username>admin</Username><SSN>999999999</SSN></Result>”);

svc.InvokeMethod(“Convert”, input1, output1);

//assign the UTF-8 converted output to the input of the XML Converter BS

var inputx = output1;

var outputx = TheApplication().NewPropertySet();

var svc = TheApplicationication().GetService(“XML Converter”);

//TheApplication().GetBusObject(“Contact”).GetBusComp(“Contact”).SetFieldValue(“lastname”,”123″);

svc.InvokeMethod(“XMLToPropSet”, inputx, outputx);

Outputs.AddChild(outputx);

COMCreateObject(“WScript.Shell”).PopUp(outputx.GetChild(6).GetValue());// It will output “admin”

Google Indic Transliteration

For urdu typing best available tool is here http://www.google.com/transliterate/indic/Urdu#

Share Record using Dynamics’ Workflow

Download Infusion.CRM.WF.CRM40ShareStep.dll from http://crm40sharestep.codeplex.com/ and paste in into YOURSERVER\Microsoft Dynamics CRM Server\Server\bin\assembly. Download plug-in registering tool from http://code.msdn.microsoft.com/crmplugin and register this dll.

1

Plugin Registration Tool 2.2

 

2

After registering your dll you can view Share Record option while creating Workflow

3

 

2

In case your are facing this error try to get CrmDiagTool4.zip from http://www.box.net/shared/6oxfqi2ida  it will give you log data. Log data will give you Version Number and Token key of dll which you will replace from xml code given below and paste it into web.config of Dynamics from IIS.

1

The classpath is dead !

Mark reinhold, Principal Engineer @ Sun Microsystems announced at Java One conference that

“Classpath is dead !”

He was discussing about Project Jigsaw.

 The primary goal of project jigsaw is to modularize the JDK which will decrease the load & deploy time of applications.

Export attachment from Notes

string fetch2 = @”<fetch mapping=”"logical”">
                  <entity name=”"annotation”">
                     <attribute name=”"documentbody”"/>
                    <attribute name=”"mimetype”"/>
                    <attribute name=”"filename”"/>
                    <attribute name=”"objectid”"/>
                    <attribute name=”"objecttypecode”"/>
                    <link-entity name=”"contact”" from=”"contactid”" to=”"objectid”"/>                        
                    <filter type=”"and”">                          
                           <condition attribute=”"filesize”" operator=”"gt”" value=”"0″”/>
                        </filter>
                  </entity>
               </fetch>”;

 String result2 = Service.Fetch(fetch2);

ShowData(result2);

private void ShowData(string data)
            {
                txtData.Text = txtData.Text + DateTime.Now.ToShortTimeString() + ” : Creating Files” + Environment.NewLine;
                             
                XmlDocument xmldoc = new XmlDocument();
                xmldoc.LoadXml(data);
                XmlNodeList xmlnode = xmldoc.GetElementsByTagName(“documentbody”);

                for (int i = 0; i < xmlnode.Count; i++)
                {

                    string filename = xmldoc.GetElementsByTagName(“filename”)[i].FirstChild.InnerText;
                    string filedata = xmldoc.GetElementsByTagName(“documentbody”)[i].FirstChild.InnerText;
                    string folder = xmldoc.GetElementsByTagName(“objectid”)[i].FirstChild.InnerText;
                    string entitytype = xmldoc.GetElementsByTagName(“objecttypecode”)[i].Attributes[0].Value;                  
                    CreateFile(folder, entitytype, filename, filedata);

                }

            }

            private void CreateFile(string folder, string entitytype, string filename, string data)
            {
              
                byte[] rawData = Convert.FromBase64String(data);

                string activeDir = @”c:\MyCompany”;

                //Create a new subfolder under the current active folder
                string newPath = System.IO.Path.Combine(activeDir, entitytype + “-” + folder.Replace(“{“, “”).Replace(“}”, “”).ToString());

                // Create the subfolder
                if (!System.IO.File.Exists(newPath))
                    System.IO.Directory.CreateDirectory(newPath);

                // Combine the new file name with the path
                newPath = System.IO.Path.Combine(newPath, filename);

                //if (!System.IO.File.Exists(newPath))
                {
                    FileStream fs = new FileStream(newPath, FileMode.Create);
                    fs.Write(rawData, 0, rawData.Length);
                    fs.Close();
                    txtData.Text = txtData.Text + DateTime.Now.ToShortTimeString() + ” : File Created -["+filename+"]” + Environment.NewLine;
                   
                }

            }

Get Partylist data in MS Dynamics 4

The PartyList type is basically a system control to display a n:n relationship.  Here is the code use to get data from partylist. In this we are getting data for phonecall activity

            foreach (BusinessEntity be in retrieved.BusinessEntityCollection.BusinessEntities)
            {
                DataRow row3 = crmEntityDataTable.NewRow();
                DynamicEntity de = (DynamicEntity)be;
                foreach (Property prop1 in de.Properties)
                {
                  PropertyInfo propInfo = prop1.GetType().GetProperty(“Value”);
                    colName = prop1.Name;
                    switch (colName)
                    {
                          case “to”:
                             if (prop1.GetType() == typeof(DynamicEntityArrayProperty))
                           {
                              DynamicEntity[] children = ((DynamicEntityArrayProperty)prop1).Value;

                              //Loop over each DynamicEntity
                              string fullName = null;
                              foreach (DynamicEntity de0 in children)
                              {
                                  //Loop over each Property in the current DynamicEntity
                                  foreach (Property prop in de0.Properties)
                                  {
                                      if (prop.GetType().Name== “LookupProperty”)
                                          if (prop.Name == “partyid”)
                                          {
                                              customername = dataExportHelper.GetValue(prop);
                                              row3["to"] = customername;
                                          }                                           
                                  }
                              }

                           }
                            break;
                        default:
                            break;
                    }

Follow

Get every new post delivered to your Inbox.