Archive for the ‘Uncategorized’ Category

How to check for User Role in Microsoft Dynamic CRM 4.0 in Form Script

Thursday, November 19th, 2009

By using Microsoft Dynamic 4.0 form script capabilities, you can easily get the current user role. This ability will help you to create custom javascript to provide another level of user interaction. The script below will give you an example to grab all the roles assigned to the current CRM user.

First of all to make our life easier, as we do not need to reinvent the wheel (creating library to connect to CRM Web Service). Thanks to the guys at Ascentium, they have created a Microsoft Dynamics CRM JavaScript SDK which you can freely download at:

http://xrm.ascentium.com/blog/crm/Post129.aspx

For this example purpose, Copy and paste the Acentium CRM SDK javascript to the Form Onload of any entity.

Then below that, we can add our own code that refer to the script. Copy and paste the following.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
// BEGIN:  ferolen  get the crrent user role scripts
var VALID_ROLENAME = "AdminGuy";
if (! UserHasRole(VALID_ROLENAME)) {
   // Do something if the user does not have the role
}
 
function UserHasRole(roleName)
{
   //create the Ascentium_CrmService object
   var oService = new Ascentium_CrmService();
   var xml = " ";
   var aoFetchResult = oService.Fetch(xml);
   for (var i = 0; i < aoFetchResult.length; i++) {
      var beResult = aoFetchResult[i];
      if (beResult.attributes["name"].value == roleName) return true;
   }
   return false;
}
// END : ferolen  get the crrent user role scripts

Setting http Proxy for Java Application

Monday, February 16th, 2009

There are 2 main ways to set/configure http proxy in your java application.

  • As a command line option when invoking the VM
  • Using the System.setProperty(String, String) in your code

There are 3 properties you can set to specify the proxy that will be used by the http protocol handler:

  • http.proxyHost: the host name of the proxy server
  • http.proxyPort: the port number, the default value being 80
  • http.nonProxyHosts: a list of hosts that should be reached directly, bypassing the proxy

Example of using command line option to set proxy configuration on java
java -Dhttp.proxyHost=webcache.mydomain.com -Dhttp.proxyPort=8080
-Dhttp.noProxyHosts=”localhost|host.mydomain.com” YourAppMainClass

Example of using code to configure proxy setting on java
//Set the http proxy to webcache.mydomain.com:8080
System.setProperty("http.proxyHost", "webcache.mydomain.com");
System.setPropery("http.proxyPort", "8080");
// Next connection will be through proxy.

There are other proxy settings that you can set as well such as https, ftp, socks.
More resources:
http://java.sun.com/javase/6/docs/technotes/guides/net/proxies.html

CSS: Float in Firefox and IE

Wednesday, August 13th, 2008

Today I come across basic problem that most web designer face. If only there was one Internet browser in the world, life would be much easier. When you float an element in IE, it does not really float, instead the margin is still affecting other element as you can see in the following illustrations:

<style type="text/css">
	body {
		width:400px;
	}
	div {
		width:200px;
		height:50px;
		background-color:#0099FF;
	}
	div#a {
		float:right;
		margin-left:10px;
		background-color:#FF9900;
	}
</style>
<body>
<div id="a">
 
</div>
 
<div id="b">
 
</div>
</body>

CSS Float experiment result in Internet Explorer 7

Now Here is what it looks like under Firefox 3.0:

CSS Float experiment result with FireFox