81 comments for trouble using | (pipe) with the String.split method

It’s good in life when you do something that helps out lots of people, some people donate money to charity, some create the iPod, others buy you a beer when you a feeling down.

my contribution to society is to help at least 81 Java programmers who have been tormented by minutes to hours of code not working when they were trying to use a | (pipe) with the String.split method.

I once came up agaisn’t this problem and as I had recently passed my Java certification I had an inkling as to why this pipe was causing me some problems.  I won’t go into the answer but it’s due to regular expressions and pipes doing something funky.

if you want to read the answer please read it here

trouble using | (pipe) with the String.split method

The reason it came up today because like all blog owners you have to put protection on otherwise people will spam your comments (really, does it work!!) and I still get people thanking me for finding the solution, even now 5 years later.

so there we go one of my contributions to society.

CRM 4 – error creating dynamic entity, check the property case

I had a frustrating error today whilst trying to create a DynamicEntity in a web service.

For some reason the code was erroring but it wasn’t giving me much of an error message.

in the end it was because the of the string property was slightly mispelt

I had this

“new_jobTitle”;

which should have been all lower case

“new_jobtitle”;

 

very frustrating indeed.  So if you want to see an example of creating a dynamic entity here you go

 

         static string nameField = "new_name";
         static string emailAddress = "new_emailaddress";
         static string code = "new_code";
         static string userID = "new_userid";
         static string jobTitle = "new_jobtitle";
         static string commision = "new_commision";
         static string phoneNumber = "new_phonenumber";
         static string salesPersonEntityName = "new_salesperson";

     /// <summary>
        /// Creates a new salesperson
        /// </summary>
        /// <param name="crmService"></param>
        /// <param name="salesPerson"></param>
        /// <returns></returns>
        public Guid createSalesperson(CrmServiceWrapper crmService, Salesperson salesPerson)
        {
            Guid salespersonID = new Guid();
     
            if (salesPerson != null)
            {
                try {

                    // Create the DynamicEntity object.
                    DynamicEntity salesPersonEntity = new DynamicEntity();
                    // Set the name of the entity type.
                    salesPersonEntity.Name = PluginQuery.salesPersonEntityName;
                    // Set the properties of the contact using property objects.
                
                    StringProperty salespersonCode = new StringProperty();
                    salespersonCode.Name = PluginQuery.code;
                    salespersonCode.Value = salesPerson.Code;
                    salesPersonEntity.Properties.Add(salespersonCode);

                    StringProperty salespersonName= new StringProperty();
                    salespersonName.Name = PluginQuery.nameField;
                    salespersonName.Value = salesPerson.Name;
                    salesPersonEntity.Properties.Add(salespersonName);

                    StringProperty salespersonPhoneNumber = new StringProperty();
                    salespersonPhoneNumber.Name = PluginQuery.phoneNumber;
                    salespersonPhoneNumber.Value = salesPerson.PhoneNumber;
                    salesPersonEntity.Properties.Add(salespersonPhoneNumber);

                    StringProperty salespersonemailAddress = new StringProperty();
                    salespersonemailAddress.Name = PluginQuery.emailAddress;
                    salespersonemailAddress.Value = salesPerson.EmailAddress;
                    salesPersonEntity.Properties.Add(salespersonemailAddress);

                    StringProperty salespersonjobTitle = new StringProperty();
                    salespersonjobTitle.Name = PluginQuery.jobTitle;
                    salespersonjobTitle.Value = salesPerson.JobTitle;
                    salesPersonEntity.Properties.Add(salespersonjobTitle);
                
                    // Create the target.
                    TargetCreateDynamic targetCreate = new TargetCreateDynamic();
                    targetCreate.Entity = salesPersonEntity;

                    // Create the request object.
                    CreateRequest create = new CreateRequest();

                    // Set the properties of the request object.
                    create.Target = targetCreate;
                    //Property prop = new Property(customernumber);

                    // Execute the request.
                    CreateResponse createResponse = (CreateResponse)crmService.Execute(create);
                    salespersonID = createResponse.id;

                } catch(Exception e){

                }
            }
            //DynamicEntity newAcc = (DynamicEntity)createResponse();
            return salespersonID;
        }