Archive for the ‘IT’ Category

Submit A Read-only or Disabled Form Field – Microsoft Dynamic CRM

Monday, May 17th, 2010

Disabling or setting a form field to read-only will cause CRM to ignore any changes to that field on save. For any reason, a form field maybe disabled or set to read-only to prevent the user change the data manually. In some cases, we may need to set the value via form Javascript.

In this case, CRM Form will not save/submit when you make any changes to these disabled fields via form script. Put the following line of script on your form onload event for every disabled/read-only field, to force CRM to submit any changes made to the field.

crmForm.all.NEW_CUSTOMFIELDNAME.ForceSubmit = true;

CRM 4.0 Create customeraddress 0x80040216 An unexpected error occurred

Thursday, March 4th, 2010

When I tried to add more address into an account in CRM, I keep getting this error with error message that doesn’t really help you nail down the problem. If you face the same error or you want to know how to create customeraddress using CRM 4.0 SDK DynamicEntity, please read through. The following simple code highlight how to add address into an account (You can also do on contact by changing the entity name “account” to “contact”. Please note that the values (i.e. street1, street2, city, …) is already set.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
var newAddress = new DynamicEntity
  {
     Name = NameOfEntity,
     Properties = new PropertyCollection()
  };
 
var prop = newAddress.Properties;
string addressName = street1 + " " + street2 + " " + city;
prop.Add(new StringProperty("name", addressName));
 
prop.Add(new StringProperty("line1", street1));
prop.Add(new StringProperty("line2", street2));
prop.Add(new StringProperty("city", city));
// .... add other details as necessary ....
prop.Add(new StringProperty("fax", fax));
prop.Add(new StringProperty("primarycontactname", contactName));
 
// .... this is the important property that you should add ...                       
prop.Add(new EntityNameReferenceProperty(AttrObjectType, new EntityNameReference("account")));
prop.Add(new LookupProperty(AttrParent, new Lookup("account", parentId)));
 
var targetCreate = new TargetCreateDynamic {Entity = newAddress};
var request = new CreateRequest {Target = targetCreate};
var response = (CreateResponse)CrmServiceUtil.GetCrmService().Execute(request);
return response.id;

Rule of thumb, do not forget to set the ParentId attribute, as well as ObjectTypeCodeId. That should do the trick. The above code uses .NET 3.0.

Dreamweaver error: while executing onLoad in RecordsetFind.htm, the following JavaScript error(s)

Thursday, July 16th, 2009

Are you getting the following errors message when using Dreamweaver CS4? (Note that it may happen to Dreamweaver Professional 8 and CS3 as well).

The following translators were not loaded due to errors:
_________.htm: has configuration information that is invalid.
….

In my case it also generate the following error message when you start and close dreamweaver.

while executing onLoad in RecordsetFind.htm, the following JavaScript error(s) occured:
In file “RecordsetFind”:
findRs is not defined

While executing onLoad in TeamAdminTempDelete.html, the following JavaScript error(s) occured:
In file “TeamAdminTempDelete”:
delTempFile is not defined

It turns out that there is something wrong with your Dreamweaver configuration files. It may be caused by file corrupt, or changes in your system.

To solve this you will have to remove the current configuration folders, so that Dreamweaver will generate new one for you. To do that, close your Dreamweaver and go to the following folder:

C:\Documents and Settings\YOUR_WINDOWS_USERNAME\Application Data\Adobe\Dreamweaver CS4\en_US

Rename the “Configuration” folder in to “Configuration-old”, and then fire up your Dreamweaver.

It should generate the new Configuration folder. Now you might loose your last configuration such as the sidebar width, last used view, etc.

Insert into / add element to array at specific position (PHP)

Wednesday, June 17th, 2009

Usually, we can search and identify PHP function just by looking at it’s name which denotes what a function does. For example array_pop(), array_push(), array_search(), array_reverse(), etc. But how about inserting an element into the middle of an array?

array_splice(array &$input, int $offset [, int $length= 0 [, mixed $replacement]] ) is the function that you are looking for. Format to use this function to add new element at certain position in an array is array_splice($array, $insert_position, 0, $element_to_insert);. See below for an example of how this function behaves.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<?php
$input = array("red", "green", "blue", "yellow");
array_splice($input, 2);
// $input is now array("red", "green")
 
$input = array("red", "green", "blue", "yellow");
array_splice($input, 1, -1);
// $input is now array("red", "yellow")
 
$input = array("red", "green", "blue", "yellow");
array_splice($input, 1, count($input), "orange");
// $input is now array("red", "orange")
 
$input = array("red", "green", "blue", "yellow");
array_splice($input, -1, 1, array("black", "maroon"));
// $input is now array("red", "green", "blue", "black", "maroon")
 
$input = array("red", "green", "blue", "yellow");
array_splice($input, 3, 0, "purple");
// $input is now array("red", "green", "blue", "purple", "yellow");
?>

Magento Layout Error after changing Base URL {{base_url}}

Sunday, June 14th, 2009

When I first login to admin menu on my Magento, I was bothered by this message at the top of my admin interface.

{{base_url}} is not recommended to use in a production environment to declare the Base Unsecure Url / Base Secure Url. It is highly recommended to change this value in your Magento configuration.

Well, most likely you will stumble upon this message on localhost installation. Please do not change this to uncorrect value or else… your Magento site will just break down. If you did it anyway, follow these steps:

  1. Go to your Magento database (you can use phpmyadmin) and open core_config_data table. Then find a row which has path = ‘web/unsecure/base_url’ and change the value back to {{base_url}}.
  2. Finally, to make it works you need to clear out any cache. Go to your magento installation, and open var folder, then delete the session folder (in other word, delete /magento/var/session).

Now, if you still want to update {{base_url}}, read this article http://www.magentocommerce.com/blog/comments/security-update-for-magento-base-url-configuration-value/. Well, in my opinion, Magento is premature product, so it is still fragile. You have to think twice before implement it on your production site.