Thursday, June 23, 2011

opening a window in dual monitor next monitor using javascript...


I was running through a requirement in which client needs to make sure the payment bill window is opened in next monitor if user is using dual monitor.
Sounds tricky in web world right? Without any controls / active X?
After running through some research (google research) I understood that its just you move your  IE window out of your screen resolution and it will start appearing in next monitor hehe!
Use following javascript to help…
<script>
function popup_params(width, height) {
    var a = typeof window.screenX != 'undefined' ? window.screenX : window.screenLeft;
    var i = typeof window.screenY != 'undefined' ? window.screenY : window.screenTop;
    var g = typeof window.outerWidth!='undefined' ? window.outerWidth : document.documentElement.clientWidth;
    var f = typeof window.outerHeight != 'undefined' ? window.outerHeight: (document.documentElement.clientHeight - 22);
    var h = (a < 0) ? window.screen.width + a : a;
    var left = parseInt(h + ((g - width) / 2), 10)+1500;
    var top = parseInt(i + ((f-height) / 2.5), 10)+1500;
    return 'width=' + width + ',height=' + height + ',left=' + left + ',top=' + top + ',scrollbars=1';
}  
window.open("http://google.com", "windowname", "location=1,toolbar=0," + popup_params(300, 300));
</script>
#trivedimehulk@gmail.com

Tuesday, June 21, 2011

"Error in line 1 position 2130. Expecting state 'Element'.. Encountered 'Text' with name '', namespace ''. "

“Error in line 1 position 2130. Expecting state 'Element'.. Encountered 'Text'  with name '', namespace ''.”
 
I was working on a BT+WCF integration project and I was continuously getting this error though I thought I did all right.
 
At times google is helpful but this time, it could not help me much. May be I tried wrong search key words. So I digged myself into what actually is happening and found out that this error means your service at some position expects element whereas you are passing something else.
 
For my case for instance my service was expecting a schema like below…
 
<student>
        <schoolInfo>
                <schName></schName>
</schoolInfo>
</student>
 
Instead I was passing
<student>
        <schoolInfo>My school</schoolInfo>
</student>
 
This was a fault in my biztalk map where I by mistake dropped a string to a element root which BT does not validate.
 
I removed the thing and mapped to correct leaf and it fixed the piece!
 
trivedimehulk@gmail.com
 
 

Wednesday, June 8, 2011

Date conversion issue in BT when parsing to WCF data contract....

There are many situations in BT applications where you receive the date as “20110506” (yyyymmdd) and when you pass such date to a date time variable to a WCF reference it will throw a conversion error at .net WCF channel level which you can look into a trace log.
 
Now to overcome this, you can use below function in script fuctoid to convert it into the date format that .net understands.
 
public string MyConcat(string param1)
{
        return System.DateTime.ParseExact(param1, "yyyyMMdd", System.Globalization.CultureInfo.CurrentCulture).ToString("yyyy-MM-dd");
}
 
trivedimehulk@gmail.com
 
 

Friday, June 3, 2011

"message part data does not contain at least one of the node"

Error: “…message part data does not contain at least one of the node….”
 
While working on BizTalk projects sometimes, when you want to manipulate a schema output (with promoted/distinguish properties), when you normally try to assign the property values in orchestration you get errors like above.
 
Easiest fix to such scene is:
 
  1. Have your schema distinguished properties
  2. Initialize a temporary variable with following syntax in orchestration expression builder
 
TempDoc=new System.Xml.XmlDocument();
TempDoc.LoadXml("<ns0:OutMsg StdName='' xmlns:ns0='http://PropSchema.OutSchema' /> "); //you can generate whole of this middle portion for your schema by using generate instance ;)
Out=TempDoc;
Out.StdName="Mehul";
 
  1. Try to access properties and assign some value.
 
 
Base rule for BT is you can’t directly access any object or its properties til its loaded in memory using a map or an intializer as shown above. J
 
Mehul Trivedi
trivedimehulk@gmail.com