tag:blogger.com,1999:blog-30038019645032973882024-03-18T10:44:15.211+02:00Microsoft Dynamics CRM 4.0 - UnleashedAdi Katzhttp://www.blogger.com/profile/16783428437179825705noreply@blogger.comBlogger102125tag:blogger.com,1999:blog-3003801964503297388.post-79338801719426925482010-07-19T23:25:00.011+03:002010-07-20T10:24:36.341+03:00CRM 4.0 Enhancing Picklists presentation layer<div></div><br /><img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 249px;border:1px solid #000000;" src="http://2.bp.blogspot.com/_M-mdv3Tfarg/TES2MmSZKlI/AAAAAAAAARI/jwiiC8lTbmQ/s400/reltypepicklist.JPG" border="0" alt=""id="BLOGGER_PHOTO_ID_5495717772851227218" /><br /><br />Picklists are usually used to provide a short range of predefined options that further describe our data. To make them usable it’s suggestible to keep the number of Picklist options to a minimum. Although a Picklist presentation layer is functional data is not always that boring and deserves a better re-presentation. <br /><br />I personally think that controls should convey more emotions and strengthen bond between what is showing and how it’s shown. Take for example a simple Picklist that has values 1-5 that describe the account rating or a Picklist of shipping methods with well known company names. No doubt presenting the following control to the user makes more sense than just selecting a number. <br /><br /><img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 392px; height: 211px;border:1px solid #000000;" src="http://3.bp.blogspot.com/_M-mdv3Tfarg/TES2MZF36nI/AAAAAAAAARA/CcwWqiNTnwQ/s400/ratingpicklist.JPG" border="0" alt=""id="BLOGGER_PHOTO_ID_5495717769309055602" /><br /><br />The concept used in this example can be developed further to support more advanced scenarios. The nice thing about it is that most of the bits that handle the actual show and hide of the Picklist menu can be reused. So if you find yourself needing to create a more complex Picklist you should center most of your effort by overriding the buildPopup function (see code).<br /><br />The code exposes most of the styling attributes which means you don’t have to tear it apart if you feel like redecorating ;+). <br /><br /><img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 384px; height: 119px;border:1px solid #000000;" src="http://3.bp.blogspot.com/_M-mdv3Tfarg/TES2LxVtsAI/AAAAAAAAAQ4/T0RPWbJ2twg/s400/categorypicklist.JPG" border="0" alt=""id="BLOGGER_PHOTO_ID_5495717758638075906" /><br /><br />In order to facilitate the construction of options and their respective images the code uses a simple technique that accepts an Image base URL and utilizes the picklist id to identify specific images folder. The image names represent their index i.e. 0.gif, 1.gif, 2.gif and so on. If need to use option’s value instead you must also change the code that constructs the image URL.<br /><br /><pre><br />CRMWeb <br /> | -- ISV <br /> |-- IMGPL (this is the ImageBaseUrl)<br /> |-- selected.gif (A small arrow that points to the selected option)<br /> |-- gi_rating (This is the Picklist id)<br /> |-- 0.gif (Empty option X image – index 0)<br /> |-- 1.gif (first option – index 1)<br /> |-- 2.gif (second option – index 2 and so on..,)<br /></pre><br /><br />Eventually the image URL is http://servername:port/iSV/IMGPL/gi_rating/1.gif<br />Feel free to comment.<br /><br /><pre class="js" name="code"><br /><br />String.prototype.Format = function( args )<br />{<br /> return this.replace( /\{(\d{1})\}/ig , function match(){return args[arguments[1]];});<br />}<br /><br />function ImagePicklist(picklistId)<br />{<br /> var ipl = this;<br /> <br /> if (!(ipl.Picklist = crmForm.all[picklistId])) <br /> return alert("Picklist is missing");<br /> <br /> if (ipl.Picklist.Disabled) <br /> return;<br /> <br /> ipl.ImageBaseUrl = "/ISV/IMGPL/";<br /> ipl.HoverStyle = {Color: "#FFFFFF",Background: "#000000"}<br /> ipl.HasEmptyOption = true;<br /> ipl.Height = 213;<br /> ipl.BackgroundColor = "#FFFFFF";<br /> ipl.Scroll = true;<br /> <br /> ipl.Picklist.ondblclick = function(){show();}<br /> ipl.Picklist.onmousedown = function(){show();}<br /> ipl.Picklist.onfocusout = function()<br /> {<br /> ipl.Picklist.Popup.document.body.innerHTML = "";<br /> ipl.Picklist.Popup.hide(); <br /> }<br /> <br /> function show()<br /> {<br /> ipl.Picklist.Disabled = true;<br /> buildPopup();<br /> var left = ipl.Picklist.Position.X;<br /> var top = ipl.Picklist.Position.Y;<br /> var width = ipl.Picklist.offsetWidth;<br /> var height = ipl.Height <br /> ipl.Picklist.Popup.show(left ,top ,width ,ipl.Height ,document.body);<br /> setTimeout(function(){ipl.Picklist.Disabled = false;},100);<br /> return false;<br /> }<br /> <br /> ipl.MouseOver = function(option)<br /> {<br /> option.style.backgroundColor = ipl.HoverStyle.Background;<br /> option.style.color = ipl.HoverStyle.Color;<br /> }<br /> <br /> ipl.MouseOut = function(option)<br /> {<br /> option.style.backgroundColor = ipl.BackgroundColor;<br /> option.style.color = "#000000";<br /> }<br /> <br /> ipl.Onclick = function(option)<br /> {<br /> ipl.Picklist.onfocusout(); <br /> ipl.Picklist.selectedIndex = option.index<br /> ipl.Picklist.focus();<br /> }<br /> <br /> function getPosition(control) <br /> { <br /> var left = 0;<br /> var top = control.offsetHeight; <br /> <br /> do {<br /> left += control.offsetLeft;<br /> top += control.offsetTop;<br /> } while (control = control.offsetParent);<br /><br /> return {X:left,Y:top}<br /> } <br /> <br /> function buildPopup()<br /> {<br /> ipl.Picklist.Position = getPosition(ipl.Picklist);<br /> ipl.Picklist.Popup.document.body.style.backgroundColor = ipl.BackgroundColor; <br /> <br /> var div = document.createElement("DIV");<br /> div.style.cssText = "overflow-y:{0};height:{1}px;".Format([(ipl.Scroll?"scroll":"hidden"),(ipl.Height-13)]);<br /> <br /> for (var i=(ipl.HasEmptyOption?0:1);i< ipl.Picklist.options.length;i++)<br /> {<br /> var option = ipl.Picklist.options[i];<br /> <br /> var item = document.createElement("DIV");<br /> item.index = i;<br /> item.onmouseover = "document.ImagePicklist.MouseOver(this);";<br /> item.onmouseout = "document.ImagePicklist.MouseOut(this)";<br /> item.onclick = "document.ImagePicklist.Onclick(this)";<br /> item.title = "Value = {0}".Format([option.value]);<br /> item.style.lineHeight = "25px"<br /> item.style.cursor = "hand";<br /> <br /> var selItem = null;<br /> if (option.selected)<br /> {<br /> selItem = document.createElement("IMG");<br /> selItem.style.height = "16px";<br /> selItem.style.width = "16px";<br /> selItem.src = "{0}selected.gif".Format([ipl.ImageBaseUrl]);<br /> selItem.align = "middle";<br /> }<br /> else<br /> {<br /> selItem = document.createElement("SPAN");<br /> selItem.innerHTML = " "; <br /> selItem.style.width = "16px";<br /> }<br /> <br /> item.appendChild(selItem);<br /> item.appendChild(document.createTextNode(" "));<br /> <br /> var img = document.createElement("IMG");<br /> img.src = "{0}{1}/{2}.gif".Format([ipl.ImageBaseUrl,ipl.Picklist.id,i]);<br /> <br /> item.appendChild(img);<br /> var optText = null;<br /> if (option.selected)<br /> {<br /> optText = document.createElement("B");<br /> optText.innerText = " {0}".Format([option.innerText]);<br /> }<br /> else<br /> {<br /> optText = document.createTextNode(" {0}".Format([option.innerText]));<br /> }<br /> item.appendChild(optText);<br /> div.appendChild(item);<br /> }<br /> <br /> ipl.Picklist.Popup.document.body.innerHTML = div.outerHTML;<br /> }<br /> <br /> { //Initialize<br /> <br /> ipl.Picklist.Popup = window.createPopup();<br /> /* A reference from the window popup to ipl */<br /> ipl.Picklist.Popup.document.ImagePicklist = ipl;<br /> <br /> var popUpBodyStyle = ipl.Picklist.Popup.document.body.style;<br /> popUpBodyStyle.border = "1px solid gray";<br /> popUpBodyStyle.padding = 0;<br /> popUpBodyStyle.margin = 5;<br /> }<br />}<br /><br />function OnCrmPageLoad()<br />{<br /> <br /> window.ctcPicklist = new ImagePicklist("customertypecode");<br /> ctcPicklist.ImageBaseUrl = "/ISV/IMGPL/";<br /> ctcPicklist.HoverStyle = {Color: "gold",Background: "#FF3454"}<br /> ctcPicklist.HasEmptyOption = false;<br /> <br /> window.accPicklist = new ImagePicklist("accountcategorycode");<br /> accPicklist.Height = 85;<br /> accPicklist.Scroll = false;<br /> accPicklist.BackgroundColor = "yellow";<br /> <br /> window.graPicklist = new ImagePicklist("gi_rating");<br /> graPicklist.Height = 165;<br /> graPicklist.Scroll = false;<br /> graPicklist.HoverStyle = {Color: "navy",Background: "#FFFFFF"}<br />}<br /><br />OnCrmPageLoad();<br /></pre>Adi Katzhttp://www.blogger.com/profile/16783428437179825705noreply@blogger.com209tag:blogger.com,1999:blog-3003801964503297388.post-82999156072922535772010-06-15T16:57:00.015+03:002010-06-15T17:38:19.587+03:00CRM 4.0 Network Resource Image Control<div></div><br /><img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 373px; height: 273px;border:solid 1px black;" src="http://4.bp.blogspot.com/_M-mdv3Tfarg/TBeQMpP8x7I/AAAAAAAAAQw/utbHUw5bcpw/s400/NRImageControl.JPG" border="0" alt=""id="BLOGGER_PHOTO_ID_5483009618252449714" /><br /><div></div><br />As the name suggest this is an on-premise / VPN solution so consider if you need this to work across the web / IFD. The idea is to utilize a simple network share together with VB 6.0 Common Control Open Dialog which can be summoned using JavaScript. The nice thing about the Dialog is that it enables you to see files as thumbnails, set the initial directory and return the selected image path into a text attribute. That’s pretty much what you need to make this work.<br /><br /><img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 268px;border:1px solid black;" src="http://3.bp.blogspot.com/_M-mdv3Tfarg/TBeNcdZQphI/AAAAAAAAAQo/-0vOGoidPus/s400/SelectAvatar.JPG" border="0" alt=""id="BLOGGER_PHOTO_ID_5483006591413298706" /><br /><br /><img style="TEXT-ALIGN: center; MARGIN: 0px auto 10px; WIDTH: 400px; DISPLAY: block; HEIGHT: 251px; CURSOR: hand;border:1px solid black;" id="BLOGGER_PHOTO_ID_5483001761203806306" border="0" alt="" src="http://3.bp.blogspot.com/_M-mdv3Tfarg/TBeJDTdk4GI/AAAAAAAAAQA/I7IWrlEs3Lw/s400/NewContact.JPG" /><br /><br />You can add an ISV toolbar button to pop the dialog but I find that this solution works hand in glove with the text image button post I wrote a while ago.<br />Here is what is did in a nutshell:<br /><br />1. Add a new text attribute. I used the pager attribute on the contact form for the sake of this example.<br /><br />2. Add a new Fixed Field 1:1 section to the contact form. This is done so the IFRAME<br />that displays the image will occupy half the screen.<br /><br /><img style="BORDER-BOTTOM: black 1px solid; TEXT-ALIGN: center; BORDER-LEFT: black 1px solid; MARGIN: 0px auto 10px; WIDTH: 354px; DISPLAY: block; HEIGHT: 375px; BORDER-TOP: black 1px solid; CURSOR: hand; BORDER-RIGHT: black 1px solid" id="BLOGGER_PHOTO_ID_5483001777259982626" border="0" alt="" src="http://4.bp.blogspot.com/_M-mdv3Tfarg/TBeJEPRqryI/AAAAAAAAAQQ/pNEzzT2J96M/s400/NewSection.JPG" /><br /><br />3. Then add a the image IFRAME and pointed it to a default blank.jpg image.<br /><br /><img style="BORDER-BOTTOM: black 1px solid; TEXT-ALIGN: center; BORDER-LEFT: black 1px solid; MARGIN: 0px auto 10px; WIDTH: 400px; DISPLAY: block; HEIGHT: 245px; BORDER-TOP: black 1px solid; CURSOR: hand; BORDER-RIGHT: black 1px solid" id="BLOGGER_PHOTO_ID_5483001771288589506" border="0" alt="" src="http://3.bp.blogspot.com/_M-mdv3Tfarg/TBeJD5B-dMI/AAAAAAAAAQI/9h_UUrbSdZk/s400/newIframe.JPG" /><br /><br />4. Arrange the form attributes as you like … here is what I did.<br /><br /><img style="BORDER-BOTTOM: black 1px solid; TEXT-ALIGN: center; BORDER-LEFT: black 1px solid; MARGIN: 0px auto 10px; WIDTH: 400px; DISPLAY: block; HEIGHT: 259px; BORDER-TOP: black 1px solid; CURSOR: hand; BORDER-RIGHT: black 1px solid" id="BLOGGER_PHOTO_ID_5483001756807201266" border="0" alt="" src="http://4.bp.blogspot.com/_M-mdv3Tfarg/TBeJDDFWAfI/AAAAAAAAAP4/E-O77WpNwhM/s400/CustForm.JPG" /><br /><br />5. Set the path attribute to read-only so selection is possible only when using the dialog.<br /><br />6. Add the following code to the contact on load event box.<br /><br />And Finally don't forget to create a network share anywhere on the server and set appropriate user permission.<br /><br /><img style="BORDER-BOTTOM: black 1px solid; TEXT-ALIGN: center; BORDER-LEFT: black 1px solid; MARGIN: 0px auto 10px; WIDTH: 283px; DISPLAY: block; HEIGHT: 400px; BORDER-TOP: black 1px solid; CURSOR: hand; BORDER-RIGHT: black 1px solid" id="BLOGGER_PHOTO_ID_5483001913262600482" border="0" alt="" src="http://3.bp.blogspot.com/_M-mdv3Tfarg/TBeJMJ7N8SI/AAAAAAAAAQg/J4l_6PofW88/s400/SharedResource.JPG" /><br /><br />That’s it … pretty simple ah … feel free to comment.<br /><br /><pre class="js" name="code"><br /><br />TextHelperButton = function(fieldId)<br />{<br /> var fldButton = this;<br /><br /> fldButton.Field = crmForm.all[fieldId];<br /><br /> if (!fldButton.Field)<br /> {<br /> return alert("Unknown Field: " + fieldId);<br /> }<br /><br /> fldButton.Click = null;<br /> fldButton.Image = new ButtonImage();<br /> fldButton.Paint = function()<br /> {<br /> var field_d = document.all[fldButton.Field.id + "_d"];<br /> if (field_d)<br /> {<br /> field_d.style.whiteSpace = "nowrap";<br /> field_d.appendChild(fldButton.Image.ToObject())<br /> }<br /> }<br /><br /> fldButton.MouseOver = function()<br /> {<br /> event.srcElement.src = fldButton.Image.MouseOver;<br /> }<br /><br /> fldButton.MouseOut = function()<br /> {<br /> event.srcElement.src = fldButton.Image.MouseOut;<br /> }<br /><br /> function ButtonImage()<br /> {<br /> this.MouseOut = "/_imgs/lookupOff.gif";<br /> this.MouseOver = "/_imgs/lookupOn.gif";<br /> this.Width = 21<br /><br /> this.ToObject = function()<br /> {<br /> var img = document.createElement("IMG");<br /> img.onmouseover = fldButton.MouseOver;<br /> img.onmouseout = fldButton.MouseOut;<br /> img.onclick = fldButton.Click;<br /> img.src = this.MouseOut;<br /> <br /> var cssText = "vertical-align:bottom;";<br /> cssText+= "margin:1px;";<br /> cssText+= "position:relative;";<br /> cssText+= "right:" + (this.Width + 1) + "px";<br /> img.style.cssText = cssText;<br /> return img;<br /> }<br /> }<br />}<br /><br />function OnCrmPageLoad()<br />{<br /> /* Build the Avatar path attribute Text Helper Button */<br /> var avaterBtn = new TextHelperButton("pager");<br /> avaterBtn.Click = SelectAvatar;<br /> avaterBtn.Paint();<br /> <br /> /* Set the avatar IFRAME when the form loads*/<br /> if (crmForm.all.pager.DataValue)<br /> {<br /> document.all.IFRAME_image.src = crmForm.all.pager.DataValue;<br /> }<br />}<br /><br />function SelectAvatar()<br />{<br /> var dialog = new ActiveXObject("MSComDlg.CommonDialog");<br /> /* You may set the filter to only show image files */<br /> dialog.Filter = "All Files (*.*)";<br /> /* Point the dialog to the current (selected) image */<br /> dialog.FileName = document.all.IFRAME_image.src;<br /> dialog.MaxFileSize = 1024;<br /> dialog.ShowOpen();<br /> <br /> /* Save the readonly path attribute with the new file selection */<br /> crmForm.all.pager.DataValue = dialog.FileName;<br /> /* Force submit since this is a readonly attribute */<br /> crmForm.all.pager.ForceSubmit = true;<br /> /* Update the image iframe */<br /> document.all.IFRAME_image.src = crmForm.all.pager.DataValue;<br />}<br /><br />OnCrmPageLoad();<br /><br /></pre>Adi Katzhttp://www.blogger.com/profile/16783428437179825705noreply@blogger.com10tag:blogger.com,1999:blog-3003801964503297388.post-81362385506866442902010-06-14T18:30:00.004+03:002010-06-14T18:46:47.897+03:00CRM 4.0 Formatting Form FieldsThe following is an intuitive Mask/UnMask JavaScript object. If you’re looking to toggle other clients (other than an entity form) you might use it as a template for a server side plug-in. The object makes it easy to enforce various types of formatting such as phone numbers , a social security number, credit card numbers and many more. The sample below formats the account Main and Other phone fields. <br /><br />When a user gives focus to a phone field the object unmasks the field’s value leaving only numbers (the original user input) or blank. Once focus is lost the mask is applied again, if a value exists, giving it its final display. The object also fires when the form is saved to support a situation where focus is not fired i.e. when the user uses the keyboard to save the record. <br /><br />There’re also other features such as displaying the format as a title or telling the mask to fire when the form loads. The later is hardly required but you might find it useful to leverage the user interaction with the form … and cleans/reformat imported/external values along the way. <br /><br />If you take a closer look you’ll notice that the object receives both a format (mask) such as “(##) ###-####” and a regular expression which is an unmask filter e.g. “\\D”. “\\D” means anything but numbers which is what you need to remove/replace to get the user’s original input.<br /><br />The code goes in the account entity onload event. <br />Give it a go and feel free to leave comments. <br /><br /><pre class="js" name="code"><br /><br />function Mask(format)<br />{<br /> var m = this;<br /> <br /> /* e.g. (##) ###-#### */<br /> m.Format = format;<br /> m.Field = null;<br /> /* OnLoad - Might be Used to cleans imported values. */<br /> m.OnLoad = false;<br /> /*<br /> A regular expression for unwanted (bad) characters. <br /> e.g. A field (e.g. phone number) original (before formatting) characters must contain numbers only. <br /> */<br /> m.Filter = null;<br /> <br /> var onloadbound = false;<br /> var onsavebound = false;<br /> var onfocusbound = false;<br /> <br /> m.Mask = function()<br /> {<br /> if (!m.Field)<br /> {<br /> return alert("Mask is missing a field");<br /> } <br /> <br /> /* Sets the textbox title to required Format */<br /> m.Field.title = m.Format; <br /> <br /> if (!onfocusbound)<br /> {<br /> onfocusbound = m.Field.attachEvent("onfocusin", unmask);<br /> m.Field.attachEvent("onfocusout", mask);<br /> }<br /> <br /> if (m.OnLoad && !onloadbound)<br /> {<br /> onloadbound = mask() == undefined;<br /> }<br /> <br /> if (!onsavebound)<br /> {<br /> onsavebound = crmForm.attachEvent("onsave",mask);<br /> }<br /> }<br /> <br /> function unmask()<br /> {<br /> m.Field.DataValue = strip();<br /> }<br /> <br /> function mask()<br /> {<br /> /* Reformat */<br /> var formated = m.Format;<br /> /* value as Array of characters */<br /> <br /> var splitValue = strip().split("");<br /> <br /> if (splitValue.length == 0)<br /> {<br /> m.Field.DataValue = null;<br /> return;<br /> }<br /> <br /> /* Regex defining a single placeholder */<br /> var placeHolderReg = new RegExp("#{1}");<br /> /* Replace each placeholder with a single character */<br /> for(var i = 0; i < splitValue.length ; i++)<br /> {<br /> formated = formated.replace(placeHolderReg,splitValue[i]); <br /> }<br /> <br /> m.Field.DataValue = formated;<br /> }<br /> <br /> function strip()<br /> {<br /> if (!m.Field.DataValue)<br /> {<br /> return "";<br /> }<br /> /* Strip field from unwanted characters */<br /> var valueOnlyReg = new RegExp(m.Filter,"gi");<br /> return m.Field.DataValue.replace(valueOnlyReg,"");<br /> }<br />}<br /><br />function OnCrmPageLoad()<br />{<br /> var phoneMask = new Mask("(##)###-####");<br /> phoneMask.Field = crmForm.all.telephone1;<br /> phoneMask.Filter = "\\D"; //Unmask Filter - Strip Everything which is not a Number<br /> phoneMask.Mask();<br /> <br /> var cellMask = new Mask("+(##) ### ####");<br /> cellMask.Field = crmForm.all.telephone2;<br /> phoneMask.OnLoad = true;<br /> cellMask.Filter = "\\D"; //Unmask Filter - Strip Everything which is not a Number<br /> cellMask.Mask();<br />}<br /><br />OnCrmPageLoad();<br /><br /></pre>Adi Katzhttp://www.blogger.com/profile/16783428437179825705noreply@blogger.com23tag:blogger.com,1999:blog-3003801964503297388.post-64479549199037256742009-11-21T04:26:00.006+02:002009-11-21T11:16:04.020+02:00CRM 4.0 Read Only Iframe - A better solution<div></div><br /><a href="http://1.bp.blogspot.com/_M-mdv3Tfarg/SwdP-i79YaI/AAAAAAAAAO8/a1EjvGQD1Yg/s1600/iframero.JPG"><img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 168px;border:1px solid black;" src="http://1.bp.blogspot.com/_M-mdv3Tfarg/SwdP-i79YaI/AAAAAAAAAO8/a1EjvGQD1Yg/s400/iframero.JPG" border="0" alt=""id="BLOGGER_PHOTO_ID_5406377813630345634" /></a><br /><div></div><br />I already posted about creating a read only iframe in the past but the solution offered here is by far better and integrates nicely with CRM.<br />The idea, in a nut shell, is to create an upper blocking layer inside the iframe. The layer is decorated with an alpha filter which makes it look disabled and also presents a watermark text to the user. The helper object also accepts an alert text that is shown to the user when he tries to click inside the frame.<br />Feel free to change the opacity, colors and fonts for best appearance. This code, as usual, should be pasted into the onload event handler and published.<br /><div></div><br /><pre class="js" name="code"><br /><br />function IframeReadOnlyHelper(sIframeId)<br />{<br /> var iro = this;<br /> iro.Iframe = document.getElementById(sIframeId);<br /> if (!iro.Iframe)<br /> {<br /> alert("IFRAME with id " + sIframeId + " is missing");<br /> }<br /> <br /> iro.WatermarkText = "";<br /> iro.AlertMessage = "";<br /> <br /> iro.OnIframeReady = function()<br /> {<br /> if (iro.Iframe.readyState != 'complete')<br /> {<br /> return;<br /> }<br /> <br /> var iframeDoc = iro.Iframe.contentWindow.document;<br /> var iframeBody = iframeDoc.body;<br /> var roSpan = iframeDoc.createElement("SPAN");<br /> <br /> var roStyle = "overflow:hidden;";<br /> roStyle += "position:absolute;";<br /> roStyle += "z-index:1;";<br /> roStyle += "left:0px;";<br /> roStyle += "top:0px;";<br /> roStyle += "height:100%;";<br /> roStyle += "text-align:center;";<br /> roStyle += "background-color:gray;";<br /> roStyle += "font:72px Tahoma;";<br /> roStyle += "filter:alpha(opacity=20)";<br /> <br /> roSpan.style.cssText = roStyle;<br /> <br /> iframeBody.appendChild(roSpan);<br /> <br /> if (iro.WatermarkText != "")<br /> {<br /> roSpan.innerHTML = "<div style='height:100;'><br>" + iro.WatermarkText + "</div>";<br /> }<br /> <br /> if (iro.AlertMessage != "")<br /> {<br /> roSpan.attachEvent("onclick", function(){alert(iro.AlertMessage);});<br /> }<br /> }<br /> <br /> iro.Disable = function()<br /> {<br /> iro.Iframe.onreadystatechange = iro.OnIframeReady;<br /> iro.OnIframeReady();<br /> }<br />}<br /><br />function OnCrmPageLoad()<br />{<br /> //Load IFRAME with any URL<br /> var iframeActivity = document.all.IFRAME_account_association;<br /> iframeActivity.src = "areas.aspx?oId=%7b50387202-6F73-DE11-9F19-0003FF230264%7d&oType=1&security=852023&tabSet=areaActivities";<br /> <br /> //Use IframeReadOnlyHelper <br /> var roIframe = new IframeReadOnlyHelper("IFRAME ID");<br /> roIframe.WatermarkText = "Read Only";<br /> roIframe.AlertMessage = "This Grid is Disabled";<br /> roIframe.Disable();<br />}<br /><br />OnCrmPageLoad();<br /></pre>Adi Katzhttp://www.blogger.com/profile/16783428437179825705noreply@blogger.com7tag:blogger.com,1999:blog-3003801964503297388.post-2793594274996979762009-10-11T13:06:00.011+02:002010-07-21T12:06:24.805+03:00CRM 4.0 Make your announcements come to life<div></div><br />
<a href="http://1.bp.blogspot.com/_M-mdv3Tfarg/StG8bfGsCYI/AAAAAAAAAOk/Bp2eVOVhCo4/s1600-h/htmlann.JPG"><img alt="" border="0" id="BLOGGER_PHOTO_ID_5391297409331235202" src="http://1.bp.blogspot.com/_M-mdv3Tfarg/StG8bfGsCYI/AAAAAAAAAOk/Bp2eVOVhCo4/s400/htmlann.JPG" style="border-bottom: black 1px solid; border-left: black 1px solid; border-right: black 1px solid; border-top: black 1px solid; cursor: hand; display: block; height: 127px; margin: 0px auto 10px; text-align: center; width: 400px;" /></a><br />
<div></div><br />
CRM has a nice feature (or at least a decent idea) called announcements which allows you to integrate and share textual messages with all CRM users.<br />
The main issue with announcements is that the body or description field does not interprets hyper text. <br />
<div></div><br />
Now wouldn’t it be nice to be able to integrate reach html messages into CRM using announcements. Although you can easily create your own reach text announcement mechanism and integrate it into CRM site map I actually find it more appealing leveraging an existing feature.<br />
<div></div><br />
In order to force the announcement page support HTML is made a simple modification to the home / homepage / home_news.aspx. now, since modifying CRM files is unsupported consider the ramification before actually doing so. <br />
<div></div><br />
The home_news.aspx page contains html that looks like this:<br />
<div></div><br />
<pre class="html" name="code"><body>
<table width="100%" height="100%">
<tr>
<td>
<table width="100%" height="100%" cellspacing="0" cellpadding="0" border="0">
<tr>
<td>
<div style="width:100%;height:100%;overflow-y:scroll;padding:10px; border: 1px solid #cccccc; background-color:#ffffff;">
<table width="100%" height="100%" cellspacing="2" cellpadding="3" border="0" style="table-layout:fixed;">
<col width="20"><col>
<% =RenderAnnouncements(false) %>
<tr height="100%" colspan="2"><td> </td></tr>
</table>
</div>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</pre><br />
<div></div><br />
If you take a closer look at the generated html (using iedevtoolbar) you’ll notice that the announcement messages are rendered as table rows. I wanted to make as little change to this page as possible and still support HTML. In order to do so I used a simple technique which wraps the inner body content (table element) in a textarea and reads the textarea value into a new span element as innerHTML.<br />
<div></div><br />
Here is how the page looks like after the modification is made:<br />
<div></div><br />
<pre class="html" name="code"><body>
<textarea style="display:none" id="anntext">
<table width="100%" height="100%">
<tr>
<td>
<table width="100%" height="100%" cellspacing="0" cellpadding="0" border="0">
<tr>
<td>
<div style="width:100%;height:100%;overflow-y:scroll;padding:10px; border: 1px solid #cccccc; background-color:#ffffff;">
<table width="100%" height="100%" cellspacing="2" cellpadding="3" border="0" style="table-layout:fixed;">
<col width="20"><col>
<% =RenderAnnouncements(false) %>
<tr height="100%" colspan="2"><td> </td></tr>
</table>
</div>
</td>
</tr>
</table>
</td>
</tr>
</table>
</textarea>
<span id="annhtml"></span>
<script>
window.document.all.annhtml.innerHTML = document.all.anntext.value;
</script>
</body>
</pre><br />
<div></div><br />
One thing that you need to minded of is that the html you paste in the announcement body should be a one liner. This is because the line breaks are interpreted as br elements. <br />
<div></div><br />
That’s all, enjoy your new announcement feature.Adi Katzhttp://www.blogger.com/profile/16783428437179825705noreply@blogger.com2tag:blogger.com,1999:blog-3003801964503297388.post-10250158028566131412009-10-11T01:27:00.005+02:002009-10-11T02:04:54.493+02:00CRM 4.0 cloning using entity mapping<div></div><br /><a href="http://4.bp.blogspot.com/_M-mdv3Tfarg/StEhCv42Z_I/AAAAAAAAAOc/_356DfldiIA/s1600-h/endresult.JPG"><img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 26px;border:1px solid black;" src="http://4.bp.blogspot.com/_M-mdv3Tfarg/StEhCv42Z_I/AAAAAAAAAOc/_356DfldiIA/s400/endresult.JPG" border="0" alt=""id="BLOGGER_PHOTO_ID_5391126560037562354" /></a><br /><div></div><br />In the past I wrote a few posts about cloning an entity using client side scripting. Most of the posts implemented complex script especially to non developers. I wanted to show you a simple cloning technique that leverages CRM built in features and can also work for CRM online. <br /><div></div><br />The benefits of using this technique are: <br />1. Gain full control over which attributes are cloned<br />2. Ability to change which attributes are cloned without adding / changing your code.<br />3. Usage of a very simple script that does not need to be changed when reused.<br />4. Ability to easily track the parent record from which the cloned entity originated.<br /><div></div><br />Following is the list of built in CRM features I am going to utilize in the post:<br />1. Creation of CRM form toolbar button <br />2. Creation of entity relationship. <br />3. Creation of mapping between related entities.<br />4. Adding simple script to the cloned entity onload handler.<br /><div></div><br />So how can we actually make the above features work to our advantage. The main feature that lies in the heart of this technique is the ability to create a self referencing relationship between the an entity to itself and use the mapping wizard to tell CRM which attributes we what to pass from the parent record. Once we have that all that remains is to understand how CRM uses the mapping on the client side much like when you create a child contact record from within an account from. <br /><div></div><br />If you take a close look at the URL that is used by CRM when you create a child related record you’ll notice that the URL uses a specific format that tells CRM what is the parent record id and type. Once you learn how to replicate this behavior you’re half way implementing this solution. <br />The following script which you’ll eventually need to paste in the entity onload event handler shows how to construct the child record or in our case the cloned record url:<br /><div></div><br /><pre class="js" name="code"><br />Clone = function()<br />{<br /> var cloneUrl = location.pathname + "?";<br /> cloneUrl += "_CreateFromType=" + crmForm.ObjectTypeCode + <br /> cloneUrl += "&_CreateFromId=" + crmForm.ObjectId + <br /> cloneUrl += "&etc=" + crmForm.ObjectTypeCode + "#";<br /> <br /> var cloneFeatures = 'toolbars=0,status=1,width=' + document.body.offsetWidth + "height=" + document.body.offsetHeight; <br /> <br /> window.open(cloneUrl,'',cloneFeatures);<br />}<br /></pre><br /><div></div><br />Once we have the script in place we need to add a toolbar button that will fire the actual cloning process. <br />Following is a sample clone button xml which you should add to your isv.config <br /><div></div><br /><pre class="xml" name="code"><br /> <Entity name="gi_test"><br /> <ToolBar ValidForCreate="0" ValidForUpdate="1"><br /> <Button Icon="/_imgs/ico_18_debug.gif" JavaScript="Clone();"><br /> <Titles><br /> <Title LCID="1033" Text="Clone" /><br /> </Titles><br /> <ToolTips><br /> <ToolTip LCID="1033" Text="Clone" /><br /> </ToolTips><br /> </Button><br /> <ToolBarSpacer /><br /> </ToolBar><br /> </Entity><br /></pre><br /><div></div><br />Next you’ll need to create a self referencing relationship. To do that open the entity customization and select 1:N relationship. Then select create new relationship. Inside the relationship form choose the same entity on both sides of the relationship. You should select not to display the left navigation link. The bellow image encapsulates the process of creating the self referencing relationship. <br /><div></div><br /><a href="http://3.bp.blogspot.com/_M-mdv3Tfarg/StEaCE_TEBI/AAAAAAAAAOE/OeVRtlcsiK4/s1600-h/selfref.JPG"><img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 322px;border:1px solid black;" src="http://3.bp.blogspot.com/_M-mdv3Tfarg/StEaCE_TEBI/AAAAAAAAAOE/OeVRtlcsiK4/s400/selfref.JPG" border="0" alt=""id="BLOGGER_PHOTO_ID_5391118851940487186" /></a><br /><div></div><br />Once the relationship is saved you’ll see a mapping link on the relationship form. Select the mapping link to open the mapping wizard.<br />Add as much mapping as required. Before you publish the entity consider the final step.<br /><div></div><br /><a href="http://4.bp.blogspot.com/_M-mdv3Tfarg/StEacZTrmkI/AAAAAAAAAOM/4ku4mzdr4Bc/s1600-h/mapping.JPG"><img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 45px;border:1px solid black;" src="http://4.bp.blogspot.com/_M-mdv3Tfarg/StEacZTrmkI/AAAAAAAAAOM/4ku4mzdr4Bc/s400/mapping.JPG" border="0" alt=""id="BLOGGER_PHOTO_ID_5391119304071289410" /></a><br /><div></div><br />Finally, if you wish to track the originating record you only need to add the entity lookup (parent test in this case) that was created as a result of the self referencing relationship. You can also set the lookup field as read only so users can’t change it manually.<br /><div></div><br /><a href="http://1.bp.blogspot.com/_M-mdv3Tfarg/StEbn_SWSwI/AAAAAAAAAOU/m6mCgonsjOY/s1600-h/originatingrecord.JPG"><img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 205px;border:1px solid black;" src="http://1.bp.blogspot.com/_M-mdv3Tfarg/StEbn_SWSwI/AAAAAAAAAOU/m6mCgonsjOY/s400/originatingrecord.JPG" border="0" alt=""id="BLOGGER_PHOTO_ID_5391120602756434690" /></a><br /><div></div><br />That’s it! publish your entity and you’re done.Adi Katzhttp://www.blogger.com/profile/16783428437179825705noreply@blogger.com53tag:blogger.com,1999:blog-3003801964503297388.post-17917896941677665512009-10-10T10:27:00.006+02:002009-10-10T11:54:15.114+02:00CRM 4.0 Creating Inline Toolbar and Buttons<div></div><br />Here is a nice usability feature that I really like. Currently CRM 4.0 only supports adding functional buttons via form toolbar. This suffices most of the time and mainly on strait forward data input forms. But as CRM takes giant leaps toward becoming a xRM platform, as an application architect and designer, you bow to search for more flexible ways to convey the system to the end user. <br /><div></div><br />The following post presents a simple and effective way of adding an inline toolbar buttons at the section level. This is especially useful when creating complex data entry forms like designers and wizards that require multi-step / section oriented logic. It is also much more simpler to add a button to the form then going through the entire isv.config process. <br /><div></div><br />Adding an inline toolbar to the form is pretty simple and involves 2 steps. <br />The first step is to add a new text field to the form, where you want the toolbar to appear (e.g. gi_toolbar) and hide it’s label through the form field customizations (i.e. double click on the field and uncheck display label on form checkbox).<br /><div></div><br />Here is how it looks after the above step is completed:<br /><div></div><br /><img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 212px;border:1px solid black;" src="http://3.bp.blogspot.com/_M-mdv3Tfarg/StBGSYmLpMI/AAAAAAAAAN0/t_2hSc1Bwd0/s400/Cusotmization.JPG" border="0" alt=""id="BLOGGER_PHOTO_ID_5390886035616670914" /><br /><div></div><br />The final step is to add the following code to the entity onload event handler and add an OnCrmPageLoad function which creates a new instance of InlineToolbar and adds the necessary buttons.<br /><div></div><br />The end result looks like this:<br /><div></div><br /><img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 57px;border:1px solid black;" src="http://2.bp.blogspot.com/_M-mdv3Tfarg/StBGSrhhkKI/AAAAAAAAAN8/l9QCmfk_3Lo/s400/Runtime.JPG" border="0" alt=""id="BLOGGER_PHOTO_ID_5390886040697409698" /><br /><div></div><br /><br /><pre class="js" name="code"><br />function InlineToolbar(containerId)<br />{<br /> var toolbar = this;<br /> var container = document.all[containerId];<br /> <br /> if (!container)<br /> {<br /> return alert("Toolbar Field: " + containerId + " is missing");<br /> }<br /> <br /> container.style.display = "none";<br /> container = container.parentElement;<br /> <br /> toolbar.AddButton = function(id,text,width,callback,imgSrc)<br /> {<br /> var btn = document.createElement("button");<br /> var btStyle = new StyleBuilder();<br /> btStyle.Add( "font-family" , "Arial" );<br /> btStyle.Add( "font-size" , "12px" );<br /> btStyle.Add( "line-height" , "16px" );<br /> btStyle.Add( "text-align" , "center" );<br /> btStyle.Add( "cursor" , "hand" );<br /> btStyle.Add( "border" , "1px solid #3366CC" );<br /> btStyle.Add( "background-color" , "#CEE7FF" );<br /> btStyle.Add( "background-image" , "url( '/_imgs/btn_rest.gif' )" );<br /> btStyle.Add( "background-repeat" , "repeat-x" );<br /> btStyle.Add( "padding-left" , "5px" );<br /> btStyle.Add( "padding-right" , "5px" );<br /> btStyle.Add( "overflow" , "visible" );<br /> btStyle.Add( "width" , width );<br /> <br /> btn.style.cssText = btStyle.ToString();<br /> btn.attachEvent("onclick",callback);<br /> btn.id = id;<br /> <br /> if (imgSrc)<br /> { <br /> var img = document.createElement("img");<br /> img.src = imgSrc;<br /> img.style.verticalAlign = "middle";<br /> btn.appendChild(img);<br /> btn.appendChild(document.createTextNode(" "));<br /> var spn = document.createElement("span");<br /> spn.innerText = text;<br /> btn.appendChild(spn);<br /> }<br /> else<br /> {<br /> btn.innerText = text;<br /> }<br /> <br /> container.appendChild(btn);<br /> container.appendChild(document.createTextNode(" "));<br /> <br /> return btn;<br /> }<br /> <br /> toolbar.RemoveButton = function(id)<br /> {<br /> var btn = toolbar.GetButton(id)<br /> if (btn)<br /> {<br /> btn.parentNode.removeChild(btn);<br /> }<br /> }<br /> <br /> toolbar.GetButton = function(id)<br /> {<br /> return document.getElementById(id);<br /> }<br /> <br /> function StyleBuilder()<br /> {<br /> var cssText = new StringBuilder();<br /> this.Add = function( key , value ){cssText.Append( key ).Append( ":" ).Append( value ).Append( ";" );}<br /> this.ToString = function(){return cssText.ToString();} <br /> }<br /><br /> function StringBuilder()<br /> {<br /> var parts = [];<br /> this.Append = function( text ){parts[ parts.length ] = text;return this;}<br /> this.Reset = function(){parts = [];}<br /> this.ToString = function(){return parts.join( "" );}<br /> }<br />}<br /><br />/* Start Script Execution */<br />function OnCrmPageLoad()<br />{<br /> window.GeneralToolbar = new InlineToolbar("gi_toolbar");<br /> GeneralToolbar.AddButton("btnReset","Reset","15%",Reset_Click);<br /> GeneralToolbar.AddButton("btnLookup","Lookup","10%",Lookup_Click);<br /> //GeneralToolbar.RemoveButton("btnLookup");<br /> GeneralToolbar.AddButton("btnAddNote","Create Note","16px",AddNote_Click,"/_imgs/ico_16_5_d.gif");<br />}<br /><br />function Reset_Click()<br />{<br /> alert('Reseting Fields...');<br />}<br /><br />function Lookup_Click()<br />{<br /> alert('lookup records...');<br />}<br /><br />function AddNote_Click()<br />{<br /> alert('Add new note');<br />}<br /></pre>Adi Katzhttp://www.blogger.com/profile/16783428437179825705noreply@blogger.com11tag:blogger.com,1999:blog-3003801964503297388.post-49493954910469660842009-09-29T13:59:00.005+02:002009-09-29T14:07:01.698+02:00CRM 4.0 Deploying a custom assembly<div></div><br />The most common and suggested deployment scenario for custom CRM web extensions (i.e. custom web service or web application) is to deploy them under the ISV folder (e.g. ISV / MyApp) and put the application assembly inside the CRMWeb \ bin folder (or wwwroot / bin when deployed on the default website). <br /><div></div><br />As of rollup2 MS also recommends putting the product assemblies of your custom extensions in their own bin folder (i.e. ISV / MyApp / bin). This option also requires you to add an assembly directive <br /><pre class="xml" name="code"><br /><%assembly name=”MyApp” %><br /></pre> <br /><div></div><br />to all your pages so the asp.net will be able to bind to your server side code behind. <br /><div></div><br />Here is an example:<br />Test.aspx<br /><pre class="xml" name="code"><br /><%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Test.aspx.cs" Inherits="MyApp.Test" %><br /><%@ Assembly Name="MyApp" %><br /></pre><br /><div></div><br />Deployment Tree:<br /><pre class="xml" name="code"><br />CRMWeb \ wwwroot<br /> |-- ISV <br /> |-- MyApp<br /> |-- bin<br /> |-- MyApp.dll<br /></pre><br /><div></div><br />Looks simple enough but many find that this does not work and produces the error <br /><pre class="xml" name="code"><br />[HttpException: Could not load type 'MyApp.Test'].<br /></pre><br /><div></div><br />The reason this does not work is that in order for asp.net to recognize and load your assembly the assembly directive must be the first directive in the page e.g. <br /><pre class="xml" name="code"><br /><%@ Assembly Name="MyApp" %><br /><%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Test.aspx.cs" Inherits="MyApp.Test" %><br /></pre><br /><div></div><br />And lastly a few tips to ensure successful deployment for both IFD and On-Premise environments:<br />Ensure that the MyApp folder is a regular Virtual Directory (not an application) – in other word your app will run under CRMAppPool.<br />Remove any application level nodes from your application web.config e.g. <br /><pre class="xml" name="code"><br /><authentication mode="Windows" /><br /></pre>Adi Katzhttp://www.blogger.com/profile/16783428437179825705noreply@blogger.com14tag:blogger.com,1999:blog-3003801964503297388.post-60876102057089668242009-09-13T14:06:00.005+03:002009-09-13T21:15:21.973+03:00CRM 4.0 Records Per Page Wizard<div></div><br /><a href="http://1.bp.blogspot.com/_M-mdv3Tfarg/SqzS7ltsnBI/AAAAAAAAANs/jAhqUzddt1Q/s1600-h/RPP.JPG"><img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 271px;border:1px solid black;" src="http://1.bp.blogspot.com/_M-mdv3Tfarg/SqzS7ltsnBI/AAAAAAAAANs/jAhqUzddt1Q/s400/RPP.JPG" border="0" alt=""id="BLOGGER_PHOTO_ID_5380907575978794002" /></a><br /><div></div><br />A few months back I answered a <a href="http://social.microsoft.com/forums/en-us/crm/thread/ad6b29b9-279b-4f62-8cef-b5bca53c7106">thread on ms forums</a> regarding running a workflow on more then 250 records which is the grid paging limit. I trimmed our record per page wizard and made it available for free on GI company website -> free wizards (left navigation).<br /><div></div><br />If you’re looking for a cool productivity enhancement that lets you control how many records are displays per entity this one is surly something any user can appreciate. Feel free to send us feedbacks (feedback@gicrm.com).<br /><br />RPP Wizard features:<br /><ul><br /><li>Runs from CRM main application toolbar.</li><br /><li>Identifies the current entity being browsed and loads with user the settings (either CRM paginglimit or saved setting).</li><br /><li>Refreshes the current entity view.</li><br /><li>Supports all views including associated views.</li><br /><li>Supports quick and advanced find.</li><br /></ul>Adi Katzhttp://www.blogger.com/profile/16783428437179825705noreply@blogger.com1tag:blogger.com,1999:blog-3003801964503297388.post-46701646212574948482009-09-10T08:01:00.005+03:002009-09-12T01:37:30.232+03:00CRM 4.0 Running an On Demand Workflow from JavaScript<div></div><br /><a href="http://3.bp.blogspot.com/_M-mdv3Tfarg/SqiOdLPw9uI/AAAAAAAAANk/C2kwYqs9POE/s1600-h/pic.JPG"><img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 148px;border:1px solid black" src="http://3.bp.blogspot.com/_M-mdv3Tfarg/SqiOdLPw9uI/AAAAAAAAANk/C2kwYqs9POE/s400/pic.JPG" border="0" alt=""id="BLOGGER_PHOTO_ID_5379706386780321506" /></a><br /><div></div><br />Running a workflow from JavaScript is a great alternative to developing server side (web services) components. This is since the workflow designer is able to accomplish many programmable tasks without actually writing complex dot.net code. Implementing a simple JS framework that activates workflows is a great enhancement to any CRM project and can simplify many of your tasks. <br /><br />The code integrates the notification (yellow ribbon) as a textual progress bar so the user can observe the progress of his actions. <br />The code also exposes a few properties that control the interval (in milliseconds) that checks the WF status, whether to refresh the page automatically or not and so forth.<br /><br />The OnCrmPageLoad function below demonstrates the usage of the OnDemandWorkflow class. Paste the entire code in your onload event<br />and set the OnDemandWorkflow instance with the correct workflow id and properties.<br /><br />Don’t forget to check your workflow as On Demand if you need to run them from code. You should also consider the logic that implements the client side call since user interaction can cause your workflow to run more then once.<br /><br />Enjoy…<br /><br /><pre class="js" name="code"><br />function OnDemandWorkflow()<br />{<br /> var odw = this;<br /> var request = null;<br /> <br /> odw.DefaultProgress = new ProgressInfo();<br /> odw.WorkflowId = "";<br /> odw.OperationId = "";<br /> odw.EntityId = "";<br /> odw.Name = "";<br /> odw.WorkflowStatus = -1;<br /> odw.OnFinishCallback = null;<br /><br /> function UpdateNotification(msg)<br /> {<br /> if (!odw.DefaultProgress.Visible)<br /> {<br /> return; <br /> }<br /> <br /> var notification = document.all.Notifications;<br /> notification.style.display = "inline";<br /> notification.style.width = "100%";<br /> notification.style.height = "20px";<br /> notification.innerHTML = odw.Name + ": <b>" + msg + "</b>";<br /> }<br /> <br /> odw.Activate = function(sWorkflowId)<br /> {<br /> UpdateNotification("Activated");<br /> <br /> if (sWorkflowId)<br /> {<br /> odw.WorkflowId = sWorkflowId<br /> }<br /> <br /> if (!odw.WorkflowId)<br /> {<br /> return UpdateNotification("Missing Workflow ID");<br /> }<br /> <br /> if (!odw.EntityId && crmForm.FormType == 2)<br /> {<br /> odw.EntityId = crmForm.ObjectId;<br /> }<br /> else if (!odw.EntityId)<br /> {<br /> return UpdateNotification("Workflow is missing an Entity name");<br /> }<br /> <br /> var xmlActReq = new StringBuilder();<br /> xmlActReq.Append(GenerateSoapHeader());<br /> xmlActReq.Append("<Execute xmlns='http://schemas.microsoft.com/crm/2007/WebServices'>");<br /> xmlActReq.Append("<Request xsi:type='ExecuteWorkflowRequest'>");<br /> xmlActReq.Append("<EntityId>").Append(odw.EntityId).Append("</EntityId>");<br /> xmlActReq.Append("<WorkflowId>").Append(odw.WorkflowId).Append("</WorkflowId>");<br /> xmlActReq.Append("</Request>");<br /> xmlActReq.Append("</Execute>");<br /> xmlActReq.Append(GenerateSoapFooter());<br /> <br /> odw.Execute("Execute",xmlActReq.ToString(),odw.ActivateEnd);<br /> }<br /> <br /> odw.Execute = function(sMethodName,sXmlRequest, fCallback)<br /> {<br /> if (request)<br /> {<br /> request.abort();<br /> }<br /> request = new ActiveXObject("Microsoft.XMLHTTP");<br /> request.Open("POST", "/mscrmservices/2007/CrmService.asmx", true);<br /> request.onreadystatechange = fCallback;<br /> request.setRequestHeader("SOAPAction","http://schemas.microsoft.com/crm/2007/WebServices/" + sMethodName);<br /> request.setRequestHeader("Content-Type", "text/xml; charset=utf-8");<br /> request.setRequestHeader("Content-Length", sXmlRequest.length);<br /> request.send(sXmlRequest);<br /> }<br /> <br /> odw.ActivateEnd = function()<br /> {<br /> if (request.readyState == 4)<br /> {<br /> if (!validateResponse())<br /> {<br /> return;<br /> }<br /> <br /> odw.OperationId = request.responseXML.selectSingleNode("//Response/Id").nodeTypedValue;<br /> odw.CheckStatus();<br /> }<br /> }<br /> <br /> odw.CheckStatus = function()<br /> {<br /> var xmlChkReq = new StringBuilder();<br /> xmlChkReq.Append(GenerateSoapHeader());<br /> xmlChkReq.Append("<Retrieve xmlns='http://schemas.microsoft.com/crm/2007/WebServices'>");<br /> xmlChkReq.Append("<entityName>asyncoperation</entityName>");<br /> xmlChkReq.Append("<id>{").Append(odw.OperationId).Append("}</id>");<br /> xmlChkReq.Append("<columnSet xmlns:q1='http://schemas.microsoft.com/crm/2006/Query' xsi:type='q1:ColumnSet'>");<br /> xmlChkReq.Append("<q1:Attributes>");<br /> xmlChkReq.Append("<q1:Attribute>statuscode</q1:Attribute>");<br /> xmlChkReq.Append("</q1:Attributes>");<br /> xmlChkReq.Append("</columnSet>");<br /> xmlChkReq.Append("</Retrieve>"); <br /> xmlChkReq.Append(GenerateSoapFooter());<br /> <br /> odw.Execute("Retrieve",xmlChkReq.ToString(),odw.CheckStatusEnd);<br /> }<br /> <br /> odw.CheckStatusEnd = function()<br /> {<br /> if (request.readyState == 4)<br /> {<br /> if (!validateResponse())<br /> {<br /> return setTimeout(odw.CheckStatus, odw.DefaultProgress.CheckInterval);<br /> }<br /> <br /> odw.WorkflowStatus = request.responseXML.selectSingleNode("//q1:statuscode").nodeTypedValue;<br /> <br /> switch(parseInt(odw.WorkflowStatus))<br /> {<br /> case 30:<br /> if (odw.DefaultProgress.RefreshWhenDone)<br /> {<br /> if (odw.DefaultProgress.RequestRefresh)<br /> {<br /> window.onbeforeunload = function()<br /> {<br /> return "Operation has succeeded, Do you wish to refresh the page?";<br /> }<br /> }<br /> else<br /> {<br /> crmForm.detachCloseAlert();<br /> }<br /> <br /> setTimeout(function(){<br /> window.location.reload();<br /> },1000);<br /> }<br /> <br /> UpdateNotification("Operation has succeeded");<br /> if (odw.OnFinishCallback)<br /> {<br /> odw.OnFinishCallback(odw);<br /> }<br /><br /> break;<br /> default:<br /> <br /> switch(parseInt(odw.WorkflowStatus))<br /> {<br /> case 32: //canceled<br /> UpdateNotification("Operation was canceled");<br /> break;<br /> case 22: //canceling<br /> UpdateNotification("Operation is being canceled");<br /> break;<br /> case 31: //failed<br /> UpdateNotification("Operation has failed");<br /> break;<br /> case 20: //In progress<br /> UpdateNotification("Operation is in progress");<br /> break;<br /> case 21: //Pausing<br /> UpdateNotification("Operation is pausing");<br /> break;<br /> case 10: //Waiting<br /> UpdateNotification("Operation is waiting");<br /> break;<br /> case 0: //Waiting for resources<br /> UpdateNotification("Operation is waiting for resources");<br /> break;<br /> }<br /> <br /> return setTimeout(odw.CheckStatus, odw.DefaultProgress.CheckInterval);<br /> } <br /> }<br /> }<br /> <br /> function validateResponse()<br /> {<br /> <br /> var error = request.responseXML.selectSingleNode("//error");<br /> var faultstring = request.responseXML.selectSingleNode("//faultstring");<br /> <br /> if (error == null && faultstring == null)<br /> {<br /> return true;<br /> }<br /> else <br /> {<br /> odw.DefaultProgress.Visible = true;<br /> if (error)<br /> {<br /> UpdateNotification(error.text);<br /> }<br /> else<br /> {<br /> UpdateNotification(faultstring.text);<br /> }<br /> <br /> return false;<br /> }<br /> }<br /> <br /> function GenerateSoapHeader()<br /> {<br /> var soapHeader = new StringBuilder();<br /> soapHeader.Append("<?xml version='1.0' encoding='utf-8'?>");<br /> soapHeader.Append("<soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'");<br /> soapHeader.Append(" xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'");<br /> soapHeader.Append(" xmlns:xsd='http://www.w3.org/2001/XMLSchema'>");<br /> soapHeader.Append(GenerateAuthenticationHeader());<br /> soapHeader.Append("<soap:Body>");<br /> return soapHeader.ToString();<br /> }<br /> <br /> function GenerateSoapFooter()<br /> {<br /> var soapFooter = new StringBuilder();<br /> soapFooter.Append("</soap:Body>");<br /> soapFooter.Append("</soap:Envelope>");<br /> return soapFooter.ToString();<br /> }<br /> <br /> function ProgressInfo()<br /> {<br /> this.RequestRefresh = true;<br /> this.RefreshWhenDone = false;<br /> this.Visible = false;<br /> this.CheckInterval = 2000;<br /> }<br /><br /> function StringBuilder()<br /> { <br /> var parts = []; <br /> this.Append = function( text ){parts[ parts.length ] = text;return this;} <br /> this.Reset = function(){parts = [];} <br /> this.ToString = function(){return parts.join( "" );} <br /> } <br />}<br /><br />function OnCrmPageLoad()<br />{<br /> if (confirm("Run Workflow"))<br /> {<br /> var odWorkflow = new OnDemandWorkflow();<br /> /* The workflow name - for presentation */<br /> odWorkflow.Name = "Create Task"; <br /> var odwProgress = odWorkflow.DefaultProgress;<br /> /* true is default - true = user has to approve the page reload. */<br /> odwProgress.RequestRefresh = false; <br /> /* false is default - true = try to refresh when the workflow is done successfully. */<br /> odwProgress.RefreshWhenDone = true; <br /> /* false is default - true = see notification progress */<br /> odwProgress.Visible = true; <br /> /* 2000 is default - ping the server each x milliseconds */ <br /> odwProgress.CheckInterval = 1000; <br /> odWorkflow.WorkflowId = "76f5cecb-987c-4635-8d78-66d2caa2f9ae";<br /> /* default Entity Id - the entity instance id (guid) */<br /> odWorkflow.EntityId = crmForm.ObjectId; <br /> odWorkflow.OnFinishCallback = CallmeWhenTheWFIsDone<br /> odWorkflow.Activate();<br /> }<br />}<br /><br />function CallmeWhenTheWFIsDone(odw)<br />{<br /> if (odw.WorkflowStatus == 30)<br /> {<br /> alert('more code here');<br /> }<br />}<br /><br />OnCrmPageLoad();<br /></pre>Adi Katzhttp://www.blogger.com/profile/16783428437179825705noreply@blogger.com4tag:blogger.com,1999:blog-3003801964503297388.post-6330361563565578732009-09-08T11:31:00.003+03:002009-09-09T22:56:50.979+03:00Formatting CRM DateTime Field<div></div><br />As you might have noticed CRM DateTime field DataValue returns the following value: “Tue Sep 29 13:00:00 PDT 2009”<br />Sometimes you need to change the value to another format e.g. dd/mm/yyyy or mm-dd-yyyy hh:MM. <br />This is quite easy to do with C# since the format string is pretty extensive however the JavaScript Date object is pretty slim and so the only option is to write your own framework / prototype extension. <br /><br />The following script extends the JavaScript Date Object and adds a toFormattedString function which accepts common format strings such as<br />dd – days, mm – months, yyyy – full year, hh – hours , MM – minutes , ss – seconds , ms – milliseconds , APM – AM/PM<br />You can extend the prototype function further if you require additional formatting.<br /><br />Here is the code and usage example:<br /><pre class="js" name="code"><br />Date.prototype.toFormattedString = function(format)<br />{<br /> var d = this;<br /> var f = "";<br /> f = f + format.replace( /dd|mm|yyyy|MM|hh|ss|ms|APM|\s|\/|\-|,|\./ig , <br /> function match()<br /> {<br /> switch(arguments[0])<br /> {<br /> case "dd": <br /> var dd = d.getDate();<br /> return (dd < 10)? "0" + dd : dd;<br /> case "mm":<br /> var mm = d.getMonth() + 1;<br /> return (mm < 10)? "0" + mm : mm; <br /> case "yyyy": return d.getFullYear();<br /> case "hh": <br /> var hh = d.getHours();<br /> return (hh < 10)? "0" + hh : hh;<br /> case "MM": <br /> var MM = d.getMinutes(); <br /> return (MM < 10)? "0" + MM : MM;<br /> case "ss": <br /> var ss = d.getSeconds(); <br /> return (ss < 10)? "0" + ss : ss;<br /> case "ms": return d.getMilliseconds();<br /> case "APM": <br /> var apm = d.getHours(); <br /> return (apm < 12)? "AM" : "PM";<br /> default: return arguments[0];<br /> }<br /> });<br /><br /> return f;<br />}<br /><br />function OnCrmPageLoad()<br />{<br /> var d = new Date(crmForm.all.<DateTime Field Id>.DataValue);<br /> alert(d.toFormattedString("mm-dd-yyyy hh:MM:ss ms"));<br /> alert(d.toFormattedString("dd/mm/yyyy hh:MM APM"));<br />}<br /><br />OnCrmPageLoad();<br /></pre>Adi Katzhttp://www.blogger.com/profile/16783428437179825705noreply@blogger.com2tag:blogger.com,1999:blog-3003801964503297388.post-17917915393022174862009-09-08T09:50:00.003+03:002009-09-08T09:59:47.050+03:00CRM 4.0 Creating a Readonly picklistCRM Picklist control (HTML select tag) does not have a read-only attribute like other input html controls. The only way to make it read-only is to disable it which grays out the control completely. Once you disable the Picklist you can’t change its border or font color (i.e. make it look like a read-only field). The only way to achieve the functionality is to change the control behavior so each time the user tries to change the Picklist value the Picklist initial value is re-selected.<br /><br />Here is the JS code that does the job:<br /><br /><pre class="js" name="code"><br />function OnCrmPageLoad()<br />{<br /> ReadOnlyPicklist(crmForm.all.<picklist id>);<br />}<br /><br />function ReadOnlyPicklist(picklist)<br />{<br /> picklist.savedIndex = picklist.selectedIndex;<br /> picklist.onchange = function()<br /><br /> {<br /> this.selectedIndex = this.savedIndex;<br /> }<br />}<br /><br />OnCrmPageLoad();<br /></pre>Adi Katzhttp://www.blogger.com/profile/16783428437179825705noreply@blogger.com1tag:blogger.com,1999:blog-3003801964503297388.post-20684411783383013782009-09-08T09:45:00.005+03:002009-09-08T09:49:27.027+03:00CRM 4.0 Changing Tab OrderA while back i posted a solution for changing vertical tabbing to horizontal tabbing. The code ran a bit slow with lookups and so the code below is a revision of the previous posting with the fix.<br /><br /><pre class="js" name="code"><br />function OnCrmPageLoad()<br />{<br /> ReArangeTabIndex();<br />}<br /><br />function ReArangeTabIndex()<br />{<br /> for( var i = 0 ; i < crmForm.all.length ; i++ )<br /> {<br /> var element = crmForm.all[ i ];<br /> if (element.tabIndex)<br /> {<br /> if (element.className == "ms-crm-Hidden-NoBehavior" || element.tagName == "A")<br /> {<br /> continue;<br /> }<br /> <br /> element.tabIndex = 1000 + (i*10);<br /> }<br /> }<br />}<br /><br />OnCrmPageLoad();<br /></pre>Adi Katzhttp://www.blogger.com/profile/16783428437179825705noreply@blogger.com8tag:blogger.com,1999:blog-3003801964503297388.post-10359844958717069952009-07-18T02:19:00.004+03:002009-07-18T02:33:34.438+03:00CRM 4.0 Setting a Picklist Default Value<div></div><br />Currently Dynamics supports setting default values for two attribute types: PicklistAttributeMetaddata (Picklist) and BooleanAttributeMetadata (bit fields). If you intend to set the default using custom code you need to follow the below process:<br /><div></div><br />1. Retrieve the attribute metadata (unless you’re creating a new one) using RetrieveAttributeRequest<br />2. Cast the returned AttributeMetadata to a PicklistAttributeMetadata.<br />3. Set the picklist metadata Default value to an integer of you choice.<br />4. Update the attribute metadata using UpdateAttribute Request.<br />5. Publish the changes using PublishXml Request.<br /><div></div><br />The bellow code is a working example which sets the account Relationship Type (customertypecode) picklist to Customer (value = 3).<br /><div></div><br /><pre class="js" name="code"><br />using System;<br />using System.Collections.Generic;<br />using System.Text;<br />using Microsoft.Crm.Sdk;<br />using Microsoft.Crm.SdkTypeProxy;<br />using Microsoft.Crm.Sdk.Metadata;<br />using Microsoft.Crm.SdkTypeProxy.Metadata;<br /><br />namespace GI.Sendbox<br />{<br /> class Program<br /> {<br /> static void Main(string[] args)<br /> {<br /> try<br /> {<br /> /* Create Authenticatio Token */<br /> CrmAuthenticationToken token = new CrmAuthenticationToken();<br /> token.AuthenticationType = 0;<br /> token.OrganizationName = "MicrosoftCRM";<br /> <br /> /* Create a CrmService end point */<br /> CrmService crmService = new CrmService();<br /> crmService.UnsafeAuthenticatedConnectionSharing = true;<br /> crmService.Url = "http://localhost:5555/mscrmservices/2007/crmservice.asmx";<br /> crmService.UseDefaultCredentials = true;<br /> crmService.CrmAuthenticationTokenValue = token;<br /> <br /> /* Create a MetadataService end point */<br /> MetadataService metaService = new MetadataService();<br /> metaService.Url = "http://localhost:5555/mscrmservices/2007/metadataservice.asmx";<br /> metaService.UseDefaultCredentials = true;<br /> metaService.UnsafeAuthenticatedConnectionSharing = true;<br /> metaService.CrmAuthenticationTokenValue = token;<br /> <br /> /* Retrieve the attribute metadata */<br /> RetrieveAttributeRequest attributeRequest = new RetrieveAttributeRequest();<br /> attributeRequest.EntityLogicalName = "account";<br /> attributeRequest.LogicalName = "customertypecode"; //Relationship Type picklist<br /> <br /> RetrieveAttributeResponse attributeResponse = <br /> (RetrieveAttributeResponse)metaService.Execute(attributeRequest);<br /> <br /> /* Cast the attribute metadata to a picklist metadata */<br /> PicklistAttributeMetadata picklist = <br /> (PicklistAttributeMetadata)attributeResponse.AttributeMetadata;<br /> <br /> /* set the default value to "customer" (3) */<br /> picklist.DefaultValue = (object)3;<br /> <br /> /* update the attribute metadata */<br /> UpdateAttributeRequest updateRequest = new UpdateAttributeRequest();<br /> updateRequest.Attribute = picklist;<br /> updateRequest.EntityName = "account";<br /> updateRequest.MergeLabels = false;<br /> <br /> metaService.Execute(updateRequest);<br /><br /> /* Publish the changes */<br /> PublishXmlRequest request = new PublishXmlRequest();<br /><br /> request.ParameterXml = @"<importexportxml><br /> <entities><br /> <entity>account</entity><br /> </entities><br /> <nodes/><br /> <securityroles/><br /> <settings/><br /> <workflows/><br /> </importexportxml>";<br /><br /><br /> PublishXmlResponse response = <br /> (PublishXmlResponse)crmService.Execute(request);<br /> }<br /> catch(System.Web.Services.Protocols.SoapException sex)<br /> {<br /> Console.WriteLine(sex.Detail.OuterXml);<br /> }<br /> catch(Exception ex)<br /> {<br /> Console.WriteLine(ex.ToString());<br /> }<br /> }<br /> }<br />}<br /></pre>Adi Katzhttp://www.blogger.com/profile/16783428437179825705noreply@blogger.com1tag:blogger.com,1999:blog-3003801964503297388.post-30105211052340222282009-07-14T02:42:00.004+03:002009-07-14T02:56:52.597+03:00CRM 4.0 Logging user login information<div></div><br />Following is a simple example on how-to log a user interaction with CRM. The sample uses a simple plug-in that references the System.Web assembly. Once you create a reference to this assembly you’re able to read the HttpContext and consequently read the information you wish to log. <br /><div></div><br />The plug-in hooks into the execute message which in most cases is the first event to fire (grid event). The plug-in also writes a cookie back to the browser to mark the logging operation so it only happens once while the main crm application is opened.<br /><div></div><br />In the example I also create a simple logInfo entity with fields I’m interested in logging. <br /><div></div><br />Please not that while reading information from the httpcontext and other objects like Request might be considered supported, reading information that CRM uses like httpcontext.items[“organizationName”] or writing information to a cookie might break your support. So when you write values back to the browser make sure you’re using a well defined naming convention that will always stay unique. And instead of reading the orgname from the items collection get it from the request url.<br /><div></div><br /><pre class="js" name="code"><br />using System;<br />using System.Collections.Generic;<br />using System.Text;<br />using Microsoft.Crm.Sdk;<br />using Microsoft.Crm.SdkTypeProxy;<br />using System.Web;<br /><br />namespace GI.SandBox<br />{<br /> public class LoginHandler : IPlugin<br /> {<br /> #region IPlugin Members<br /><br /> public void Execute(IPluginExecutionContext context)<br /> {<br /> if (context.MessageName != "Execute")<br /> {<br /> return;<br /> }<br /> <br /> if (context.Stage != MessageProcessingStage.BeforeMainOperationOutsideTransaction)<br /> {<br /> return;<br /> } <br /> <br /> if (!(context.CallerOrigin is ApplicationOrigin))<br /> {<br /> return;<br /> }<br /> <br /> HttpContext webContext = HttpContext.Current;<br /> HttpCookie logInfo = webContext.Request.Cookies.Get("loginfo");<br /> <br /> if (logInfo == null)<br /> {<br /> DynamicEntity logInfoEntry = new DynamicEntity();<br /> logInfoEntry.Name = "gi_loginfo";<br /><br /> logInfoEntry.Properties.Add<br /> (<br /> new StringProperty<br /> (<br /> "gi_userhostaddress",<br /> webContext.Request.UserHostAddress<br /> )<br /> );<br /><br /> logInfoEntry.Properties.Add<br /> (<br /> new StringProperty<br /> (<br /> "gi_useridentity",<br /> webContext.User.Identity.Name<br /> )<br /> );<br /><br /> logInfoEntry.Properties.Add<br /> (<br /> new StringProperty<br /> (<br /> "gi_starturl",<br /> webContext.Request.Path<br /> )<br /> );<br /><br /> logInfoEntry.Properties.Add<br /> (<br /> new StringProperty<br /> (<br /> "gi_hostname",<br /> webContext.Request.Url.Host<br /> )<br /> );<br /><br /> if (webContext.Items["organizationName"] != null)<br /> {<br /> logInfoEntry.Properties.Add<br /> (<br /> new StringProperty<br /> (<br /> "gi_userhostaddress",<br /> webContext.Items["organizationName"].ToString()<br /> )<br /> );<br /> }<br /> <br /> logInfoEntry.Properties.Add<br /> (<br /> new CrmDateTimeProperty<br /> (<br /> "gi_datetime",<br /> new CrmDateTime(webContext.Timestamp.ToString())<br /> )<br /> );<br /> <br /> TargetUpdateDynamic targetRecord = new TargetUpdateDynamic();<br /> targetRecord.Entity = logInfoEntry;<br /> <br /> UpdateRequest updateRequest = new UpdateRequest();<br /> updateRequest.Target = targetRecord;<br /> <br /> context.CreateCrmService(true).Execute(updateRequest);<br /><br /> logInfo = new HttpCookie("loginfo");<br /> logInfo.Value = DateTime.Now.ToString();<br /> webContext.Response.Cookies.Add(logInfo);<br /> } <br /> }<br /><br /> #endregion<br /> }<br />}<br /></pre>Adi Katzhttp://www.blogger.com/profile/16783428437179825705noreply@blogger.com6tag:blogger.com,1999:blog-3003801964503297388.post-29419708670783112252009-07-12T03:48:00.006+03:002010-05-05T07:51:24.489+03:00CRM 4.0 Cascading wizard<div></div><br /><a href="http://2.bp.blogspot.com/_M-mdv3Tfarg/Slk0y2nT7CI/AAAAAAAAANU/tDXlZS_L2T8/s1600-h/main.jpg"><img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 278px;border:1px solid black;" src="http://2.bp.blogspot.com/_M-mdv3Tfarg/Slk0y2nT7CI/AAAAAAAAANU/tDXlZS_L2T8/s400/main.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5357371279992417314" /></a><br /><div></div><br />The Cascading wizard is a complementary add-on to dynamic mapping facility. Currently dynamics only supports mapping when a user creates a new child entity within a parent context (form). Knowing that many partners invest quite a bit of energy developing solutions that require cascading and having to deal with these types of requirements ourselves we decided to create a fully featured mapping / cascading wizard that enable us to complete these tasks with just a few clicks. <br /><div></div><br />The CAW wizard has the following features which can save you hours of tedious development.<br /><div></div><br />1.Mapping fields from a parent entity when a child entity is created outside of the parent form. For example: A common requirement might be to inherit account information when you create a new contact from dynamics contacts grid (view). Currently the account fields are only mapped if you create the contact from the account form.<br /><div></div><br />2.Mapping fields from multiple parents. For example: you might have an entity that has lookups to more the 1 entity. When you create the entity you might want to inherit fields from any parent.<br /><div></div><br />3.Cascading parent modifications to all children. For example: you might want to update all contacts under a certain account when the account main phone field (contact business phone) changes. <br /><div></div><br />4.The ability to decide whether to inherit parent attributes only when the child field is empty. For example: you might want to inherit account information when the contact is created but want to enable the user to change the contacts fields afterwards. The CAW wizard enables you to decide whether field changes are cascaded when the child attribute is empty.<br /><div></div><br />5.Cascading drilldown. One of the nicest features of this wizard is that it enables you to drill down the changes from the root entity to the bottom leaf.<br />For example: if you define an account to contact cascading rules and then define a contact to invoice cascading rule on the same fields. And then change the field on the account form the change is carried out to the invoice entity.<br /><div></div><br />6.The wizard integrates seamlessly with the current mapping facility. And you can choose to utilize both or just use the CAW wizard.<br /><div></div><br />Common CAW features: The wizard supports – <br />1. Both on-premise and partner hosted environments. <br />2. IFD – Internet facing deployment<br />3. 32 and 64 bit servers<br />4. Multi-Tenancy<br />5. All Languages<br />6. All Rollups<br /><div></div><br />We made a video to illustrate the above features.<br />In order to play back the video, right click on the flash movie then click rewind and play. <br /><div></div><br /><iframe src="http://www.upsite.co.il/uploaded/files/662_5d00861d7d4c0e900f160ab6aa6898c8.swf" width="680" height="534"></iframe><br /><div></div><br />If you have question regarding the wizard functionality you can ask them here of send your enquiry to support@gicrm.comAdi Katzhttp://www.blogger.com/profile/16783428437179825705noreply@blogger.com5tag:blogger.com,1999:blog-3003801964503297388.post-10297537813014765062009-07-05T15:26:00.007+03:002010-05-05T07:51:49.405+03:00CRM 4.0 Record Filter Wizard<div></div><br /><a href="http://2.bp.blogspot.com/_M-mdv3Tfarg/SlCotng1RKI/AAAAAAAAANE/K6SgETLNZ8M/s1600-h/main.jpg"><img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 300px;border:1px solid black;" src="http://2.bp.blogspot.com/_M-mdv3Tfarg/SlCotng1RKI/AAAAAAAAANE/K6SgETLNZ8M/s400/main.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5354965458597790882" /></a><br /><div></div><br />The idea behind the RFW wizard is to create a security filter in the context of each entity data and user role and expose / grant access to records only when a certain condition is met or under a certain restriction. For example: an organization might want a specific salesperson role to see leads that are connected to a specific product family or allow a low-privileged role to only see accounts that their credit limit is between a certain range.The RFW wizard will always make sure that the returned data is within the security filter parameters. <br /><div></div><br />Another good example that we use is creating a severity or scoring attributes that enables the organization to categorize each entity and then create a security filter that allows users to see data depending on the scoring attribute value. <br /><div></div><br />Actually there is no limit to the type of security filters that you can create. You can construct any filter (simple or complex) using any business logic and utilizing existing or specialized attributes to achieve a high data aware security state.<br /><div></div><br />The security filters are setup using the wizard User Interface without the need to write custom code. <br /><div></div><br />The following demonstration is a simple example of how you can take advantage of the RFW wizard.<br />The first scenario creates a security restriction on the top business unit (a template) which hides accounts that their credit limit is between 100,000 and 1 million $. This means that all the views, quick create and advance find will adhere to this restriction and only return accounts that meet the security filter.<br /><div></div><br />The second scenario overrides the template and creates a security filter on the system administrator role. This time the filter is setup on the credit hold attribute returning only accounts that their credit is not held. <br /><div></div><br />The last scenario defines a security filter for a specific marketing manager and allows him to only to view accounts that their category is set to standard.<br /><div></div><br />RFW Technical Information:<br /><div></div><br />1.Support for Internet Explorer 8, Internet Facing Deployment - IFD, and all available rollups (1 – 5).<br />2.Support for all searchable entities (entities that you can search using advanced find)<br />3.Support for Security Hierarchy i.e. creating business unit templates, overriding the templates for each CRM role and creating specific security filters for users.<br />4.Supports all views e.g. (public, private , associated , quick find , advanced find , print pages etc)<br /><div></div><br /><iframe src="http://www.upsite.co.il/uploaded/files/662_06a1b2cb64190d46acd67c5c0ede3b6a.swf" width="680" height="534" ></iframe><br /><div></div><br />If you have any questions regarding the RFW wizard post them here or send you enquiry to support@gicrm.comAdi Katzhttp://www.blogger.com/profile/16783428437179825705noreply@blogger.com3tag:blogger.com,1999:blog-3003801964503297388.post-89603496032470953122009-07-01T12:43:00.005+03:002010-05-05T07:52:09.625+03:00CRM 4.0 Auto Sharing wizard<div></div><br /><a href="http://4.bp.blogspot.com/_M-mdv3Tfarg/SlDFU5CivzI/AAAAAAAAANM/jtwBowR3AAU/s1600-h/main.jpg"><img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 167px;border:1px solid black;" src="http://4.bp.blogspot.com/_M-mdv3Tfarg/SlDFU5CivzI/AAAAAAAAANM/jtwBowR3AAU/s400/main.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5354996919643062066" /></a><br /><div></div><br />CRM 4.0 permission mechanism and access level rules can be quite limiting. This is especially true when privacy of data is required, visibility of records depends on business decisions or visibility depends on the source (role or user) which triggered the action. On other occasions you need to control visibility of record across sibling business units and business units that are not under the same branch. <br /><div></div><br />Most customers overcome the problem by granting organization access to roles which needs work with data. Of course this is very problematic and reduces the security to minimum and so they usually start looking for solution like field level security which enables the organization to hide certain entity fields from a specific business unit, role or user. <br /><div></div><br />Dynamics does address this problem using a mechanism called sharing. The problem with the sharing mechanism is that it’s a manual process which shifts the responsibility of sharing to the user. This behavior is rarely acceptable especially because sharing rules needs to adhere to specific business decisions and sharing logic. <br /><div></div><br />I’ve seen some very interesting solutions that use dynamics workflow engine to facilitate the sharing of records. However we needed a comprehensive solution and so we developed the Auto Sharing wizard which addresses most scenarios (all of ours anyway). <br /><div></div><br />Following is a technical description of the Auto Sharing wizard and what it can do for you.<br /><br />1.Creation of Global Sharing rules - Fired by anyone (We use them as sharing templates and override with specific rules).<br /> a.When the record is created<br /> b.When the record match a specific snapshot (state) <br /><br />2.Creation of Specific Sharing rules - Fired only when the current user or user role matches the sharing rule source (see video)<br /> a.When the record is created<br /> b.When the record match a specific snapshot (state)<br /><br />3.Creation of a Sharing hierarchy e.g. Rules setup as global fire first Rule setup at the Role level may override or add more sharing rules Rule setup at the User Level overrides the Role level rules and used as Sharing rule exceptions.<br /><br />4.Creation of Sharing rules that are integrated as a workflow step<br /><div></div><br />Following is a list of scenarios that can be resolved using the wizard<br /><div></div><br />Sharing of record only when a specific Role or User triggers the action<br />Conditional sharing either by using a snapshot query or by integrating the sharing rule in an “IF” workflow routine.<br />Sharing Record with lower non privileged business units, roles and users<br />Sharing Records with sibling Business units and Business unit that are not under the same branch<br /><div></div><br />ASW Presentation – in order to rewind click on the flash movie; then rewind and play.<br /><div></div><br /><iframe src="http://www.upsite.co.il/uploaded/files/662_a488ae0cee078f8fc2d95e5078c6eef9.swf" width="680" height="534"></iframe><br /><div></div><br />If you have questions regarding the wizard feel free to ask them here or send them to support@gicrm.comAdi Katzhttp://www.blogger.com/profile/16783428437179825705noreply@blogger.com0tag:blogger.com,1999:blog-3003801964503297388.post-85525821163616521262009-06-28T06:17:00.004+03:002009-06-28T06:31:48.122+03:00CRM 4.0 Working with Strings<div></div><br />Many CRM development tasks involve manipulation and concatenation of strings, whether it’s concatenating a Field DavaValue from 2 or more fields, building messages that involve dynamic data, constructing FetchXml Requests and Soap messages or constructing strings that contain CSS or other meaningful html information, in one way or another you end up writing a script that looks like the following examples:<br /><div></div><br /><pre class="js" name="code"><br />//Exampe 1<br />var someValue = “The account number: ” + crmForm.accountnumber.DataValue + “ is not valid\n”;<br /> someValue+= “More helpful info on how to fill a valid account number here.”<br /><br /> alert(someValue);<br /></pre><br />or <br /><pre class="js" name="code"><br />//Example 2<br />var iLeft = 100;<br />var iTop = 100; <br />var cssText = “position:absolute;left:” + iLeft + “;top:” + iTop + “;”;<br />document.all[“<Some Element ID>”].style.cssText = cssText;<br /></pre><br />or<br /><pre class="js" name="code"><br />//Example 3<br />var iTop = 50;<br />var iLeft = 50;<br />var iWidth = 800;<br />var iHeight = 600;<br />var windowFeature = “toolbars=0;width=” + iWidth + “,height=” + iHeight + “,top=” + iTop + “,left=” + iLeft;<br />window.open( “<Valid Url>” , “<Window Name>” , windowFeatures);<br /></pre><br />There are several disadvantages of using this simple concatenation technique: <br />1.The first which is the most obvious and <a href="http://mscrm4ever.blogspot.com/2009/06/crm-40-creating-js-resource-manager.html">discussed here</a> is the lack of multi-lingual support for text messages. If for instance you need to translate the text that appears in the first example above, how can you accomplish the task and still keep the dynamic value concatenation in the correct context? <br /><div></div><br />2. Another major disadvantage involves construction of large strings such as when you build soap message or a large FetchXml queries which can dramatically decrease IE responsiveness and cause performance issues.<br /><div></div><br />3. Large string that are constructed in this manner sometimes make it impossible to read and debug<br /><div></div><br />The following JavaScript objects facilitates these types of tasks and will help you avoid the problems mentioned above.<br /><div></div><br />The first code snippet facilitates the concatenation of strings using a class called StringBuilder (similar to C# System.Text.StringBuilder mechanism) <br /><pre class="js" name="code"><br />/* JS String Builder */<br />StringBuilder = function()<br />{<br /> var parts = [];<br /> this.Append = function( text ){parts[ parts.length ] = text;return this;}<br /> this.Reset = function(){parts = [];}<br /> this.ToString = function(){return parts.join( "" );}<br />}<br /><br />//Usage<br />function OnCrmPageLoad()<br />{<br /> //Solving example 2 <br /> var iLeft = 100;<br /> var iTop = 100; <br /> var cssText = new StringBuilder();<br /> cssText .Append(“position:absolute;left:”).Append(iLeft).Append( “;top:”).Append(iTop).Append( “;”);<br /> document.all[“<Some Element ID>”].style.cssText = cssText.ToString();<br /><br /> //Solveing example 3<br /> var iTop = 50;<br /> var iLeft = 50;<br /> var iWidth = 800;<br /> var iHeight = 600;<br /> <br /> var windowFeature = new StringBuilder();<br /> windowFeature.Append(“toolbars=0,”);<br /> windowFeature.Append(“width=”).Append(iWidth).Append( “,”);<br /> windowFeature.Append(“height=”).Append(iHeight).Append( “,”);<br /> windowFeature Append(“top=”).Append(iTop).Append(“,”);<br /> windowFeature.Append(“left=”).Append(iLeft);<br /> <br /> window.open( “<Valid Url>” , “<Window Name>” , windowFeatures.ToString()); <br />}<br /><br />OnCrmPageLaod(); <br /></pre><br />The second code snippet contains an extension function to the built-in JavaScript string object which helps you solve the problem mentioned in example 1 above and also makes it possible to write code similar to the String.Format c# method.<br /><pre class="js" name="code"><br />String.prototype.Format = function( args )<br />{<br /> var result = this.replace( /\{(\d{1})\}/ig , <br /> function match()<br /> {<br /> return args[arguments[1]];<br /> } <br /> );<br /> <br /> return result;<br />}<br /><br />function OnCrmPageLoad()<br />{<br /> //Solve Exampe 1<br /> var someValue = new StringBuilder();<br /> someValue.Append(“The account number: {0} is not valid\n”.Format([crmForm.accountnumber.DataValue]));<br /> someValue.Append(“More helpful info on how to fill a valid account number here.”);<br /><br /> alert(someValue.ToString()) <br /><br /> //Solve Example 2<br /> var iTop = 50;<br /> var iLeft = 50;<br /> var iWidth = 800;<br /> var iHeight = 600;<br /> <br /> //Create string template with place holders<br /> var windowFeature = “toolbars=0;top={0},left={1},width={2},height={3}”;<br /> //Format the String <br /> windowFeature = windowFeature.Format([iTop,iLeft,iWidht,iHeight]);<br /> window.open( “<Valid Url>” , “<Window Name>” , windowFeatures);<br />}<br /><br />OnCrmPageLoad();<br /></pre><br />The last example extends the StringBuilder class and creates a StyleBulder that is used to concatenate CSS rules with ease<br /><pre class="js" name="code"><br />StyleBuilder = function()<br />{<br /> var cssText = new StringBuilder();<br /> this.Add = function( key , value ){cssText.Append( key ).Append( ":" ).Append( value ).Append( ";" );}<br /> this.ToString = function(){return cssText.ToString();} <br />}<br /><br />//Usage<br />function OnCrmPageLoad()<br />{<br /> //Solve Example 2<br /> var iLeft = 100;<br /> var iTop = 100; <br /> var cssText = new StyleBuilder();<br /> cssText.Add(“position”,”absolute”);<br /> cssText.Add(“left”, iLeft);<br /> cssText.Add(“top”,iTop);<br /> <br /> document.all[“<Some Element ID>”].style.cssText = cssText.ToString(); <br />}<br /><br />OnCrmPageLoad();<br /></pre><br />I hope you find this interesting and helpful.Adi Katzhttp://www.blogger.com/profile/16783428437179825705noreply@blogger.com0tag:blogger.com,1999:blog-3003801964503297388.post-91726092078828194052009-06-27T18:15:00.006+03:002009-06-27T20:41:57.555+03:00CRM 4.0 Adding a helper button to text fields<div></div><br /><img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 269px; height: 30px;border:1px solid black;" src="http://4.bp.blogspot.com/_M-mdv3Tfarg/SkY4K1MExBI/AAAAAAAAAM8/pqsIK_pDDYY/s400/texthelperbutton.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5352026965903983634" /><br /><div></div><br />Sometimes you want to attach a click event to a text field. Since CRM does not provide a way to associate a button with a CRM field you need to implement the functionality using JavaScript. The following TextHelperButton object helps you achieve that goal for any given text field.<br /><div></div><br />When creating an instance of the TextHelperButton set the following parameters:<br /><strong>Image width</strong> – This is used to adjust the image positioning. <br /><strong>MouseOver image URL</strong> – The image that is displayed when you go over the button.<br /><strong>MouseOut Image URL</strong> – The default image URL <br /><strong>Click</strong> – A function to call when the user clicks on the image.<br /><div></div><br />Paste the code inside the entity onload event and enjoy...<br /><div></div><br /><pre class="js" name="code"><br />TextHelperButton = function(fieldId)<br />{<br /> var fldButton = this;<br /><br /> fldButton.Field = crmForm.all[fieldId];<br /><br /> if (!fldButton.Field)<br /> {<br /> return alert("Unknown Field: " + fieldId);<br /> }<br /><br /> fldButton.Click = null;<br /> fldButton.Image = new ButtonImage();<br /> fldButton.Paint = function()<br /> {<br /> var field_d = document.all[fldButton.Field.id + "_d"];<br /> if (field_d)<br /> {<br /> field_d.style.whiteSpace = "nowrap";<br /> field_d.appendChild(fldButton.Image.ToObject())<br /> }<br /> }<br /> <br /> fldButton.MouseOver = function()<br /> {<br /> event.srcElement.src = fldButton.Image.MouseOver;<br /> }<br /> <br /> fldButton.MouseOut = function()<br /> {<br /> event.srcElement.src = fldButton.Image.MouseOut;<br /> }<br /><br /> function ButtonImage()<br /> {<br /> this.MouseOut = "";<br /> this.MouseOver = "";<br /> this.Width = 21<br /><br /> this.ToObject = function()<br /> {<br /> var img = document.createElement("IMG");<br /> img.onmouseover = fldButton.MouseOver;<br /> img.onmouseout = fldButton.MouseOut;<br /> img.onclick = fldButton.Click;<br /> img.src = this.MouseOut;<br /> <br /> var cssText = "vertical-align:bottom;";<br /> cssText+= "margin:1px;";<br /> cssText+= "position:relative;";<br /> cssText+= "right:" + (this.Width + 1) + "px";<br /> img.style.cssText = cssText;<br /> return img;<br /> }<br /> }<br />}<br /><br />function OnCrmPageLoad()<br />{<br /> /* pass the name of the crm field as parameter */<br /> var actnButton = new TextHelperButton("name");<br /> /* set the image button width */<br /> actnButton.Image.Width = 21; //integer<br /> /* supply image rollover URLS */<br /> actnButton.Image.MouseOver = "/_imgs/lookupOn.gif";<br /> actnButton.Image.MouseOut = "/_imgs/lookupOff.gif";<br /> /* supply an function that is called when the image is clicked */<br /> actnButton.Click = Accountnumber_Click;<br /> /* add the image next to the field */<br /> actnButton.Paint();<br />}<br /><br />function Accountnumber_Click()<br />{<br /> alert('Account Number Field Clicked');<br />}<br /><br />OnCrmPageLoad();<br /></pre>Adi Katzhttp://www.blogger.com/profile/16783428437179825705noreply@blogger.com2tag:blogger.com,1999:blog-3003801964503297388.post-12820254526703929672009-06-27T04:47:00.004+03:002009-06-27T05:01:40.518+03:00CRM 4.0 Creating a JS Resource ManagerThe purpose of this post is to present a simple and effective way of handling multi-lingual text resources on the client (CRM) Form. <br /><br />In most projects an application is built to address a single language. Knowing that from the get go simplifies the way developers weave (hard code) the application messages into each entity form.<br /><br />Let’s assume, for example, that you need to validate that the account number starts with the letters “ACT ”. Your code might look like the following example:<br /><br /><pre class="js" name="code"><br />if (/^ACT\s{1}/.test(crmForm.accountnumber.DataValue) == false)<br />{<br /> alert(”Account number must begin with ACT ”);<br />}<br /></pre><br /><br />This is a very simple and strait forward way to present messages to the user. However since CRM is a multi-lingual application using this approach is far from being a best practice. The reason is that your client might decide (eventually) to add another language to the system and once he does that you must rewrite you application to support the new language. Assuming you have a small amount of messages you might consider changing your code as follows:<br /><br /><pre class="js" name="code"><br />if (/^ACT\s{1}/.test(crmForm.accountnumber.DataValue) == false)<br />{<br /> if (USER_LANGUAGE_CODE == 1033) //English United States<br /> {<br /> alert(”Account number must begin with ACT ”);<br /> }<br /> else if (USER_LANGUAGE_CODE == 1043) //Dutch<br /> {<br /> alert(”Rekeningnummer moet beginnen met ACT ”);<br /> }<br />}<br /></pre><br /><br />Now, as long as the application stays small this solution should hold. However, applications tend to grow over time and from a certain point the amount of messages will be too overwhelming to manage in this manner. <br /><br />Another reason why this approach is a bad practice is that is obligates or ties the client to an ever lasting development phase. The best approach is to shift the responsibility of handling multi-lingual tasks to the client and the best way to do that is to create a resource manager that enables you to support multi-lingual messages from your first line of code.<br /><br />So how do we shift responsibility of translating our application messages to the client?<br />The simplest approach is to create a new text attribute for each message that you need to display. The text attribute display name can hold the message it self. For example:<br /><br />New Attribute: new_msginvalidaccountnumber <br />Display Name: The account number must begin with “ACT “<br />Searchable: No<br />Required:No<br /><br />Now, put the new attribute on the CRM form under a new tab called Labels and hide it when the form loads. E.g.<br /><br /><pre class="js" name="code"><br />function OnCrmPageLoad()<br />{ <br /> document.all.tab4Tab.style.display = “none” //assuming that the fifth tab is the Labels tab.<br />}<br /><br />OnCrmPageLoad();<br /></pre><br /><br />Now, let’s transform the above code so it would support any language<br /><br /><pre class="js" name="code"><br />/* --< Resource Manager >-- */<br />ResourceManager = function()<br />{<br /> var rm = this;<br /> rm.GetString = function( resId )<br /> {<br /> var resource = document.getElementById( resId ); <br /> if ( !resource ) <br /> {<br /> /* Show missing label */<br /> return "[" + resId + "]";<br /> }<br /> <br /> return crmForm.GetLabel( resource );<br /> } <br />}<br />/* Create an instance of Resource Manager */<br />RM = new ResourceManager();<br /><br />if (/^ACT\s{1}/.test(crmForm.accountnumber.DataValue) == false)<br />{<br /> alert(RM.GetString(“new_msginvalidaccountnumber”));<br />}<br /></pre><br /><br />Integrate the resource manager to each entity onload event.<br /><br />Good luck…Adi Katzhttp://www.blogger.com/profile/16783428437179825705noreply@blogger.com0tag:blogger.com,1999:blog-3003801964503297388.post-52815524754650216562009-06-12T13:53:00.007+03:002009-06-12T14:32:20.056+03:00Summarizing an Appointment field on a Parent Entity<div></div><br />Imagine you have a custom field called number of participants on and appointment entity and you want to summarize this field for all the appointments under the same regarding parent.<br /><div></div><br />This looks simple at first glance i.e. register a plug-in on the <b>parent</b> post Create and Update messages and you’re done. However, since this entity is part of dynamics scheduling engine and affects rescheduling you also need to register your plug-in on the Book and Reschedule messages. <br /><div></div><br />Actually the Book and Reschedule messages somewhat replace the Create and Update messages. That means that when you create a new Appointment the Book message is fired and when you Update an existing appointment the reschedule message is fired. <br /><div></div><br />So why do we need to also register the plug-in on the Create and Update messages? <br />The answer is that when you reschedule or book an appointment and the user is not available at that point in time the scheduling engine halts the execution and enables the user to cancel the operation. If the user decide to disregard (ignore) that warning and save anyway then the Create or Update are fired to complete the operation.<br /><div></div><br />Since the summarizing of the field can be a long operation you should also register the plug-in for asynchronous execution. <br /><div></div><br />Another thing that is worth mentioning is code synchronization. Since CRM does not lock record and two users can update the same appointment at the same time it is also advisable to lock the process that updates the parent field to avoid data corruption.<br /><div></div><br />Last Important remark: the regarding lookup (parent entity) is required for this operation. Since the Book and Reschedule messages don’t allow you to register Post Images you need to send the regarding field in each operation. E.g. <br /><div></div><br />//Put this code in the appointment onload event handler<br /><pre class='js' name='code'><br />if (crmForm.regardingobjectid.DataValue != null)<br />{<br /> crmForm.regardingobjectid.ForceSumbit = true;<br />}<br /></pre><br /><div></div><br />Plug-in Registered on the Reschedule, Book, Create and Update Asynchronous Parent Pipeline<br /><div></div><br /><pre class='csharp' name='code'><br />using System;<br />using System.Collections.Generic;<br />using System.Text;<br />using Microsoft.Crm.Sdk;<br />using Microsoft.Crm.SdkTypeProxy;<br />using Microsoft.Crm.Sdk.Query;<br /><br />namespace GI.Crm.Sandbox<br />{<br /> <br /> public class SummarizeAppointmentFieldHandler : IPlugin<br /> {<br /> private Object SyncObject = new Object();<br /> <br /> public void Execute(IPluginExecutionContext context)<br /> {<br /> /* Validates that the user is available */<br /> if (context.OutputParameters.Contains(ParameterName.ValidationResult))<br /> {<br /> ValidationResult validationResult = <br /> context.OutputParameters[ParameterName.ValidationResult] as ValidationResult;<br /> if (validationResult.ValidationSuccess == false)<br /> {<br /> return;<br /> }<br /> }<br /> <br /> /* Validate Target Entity */<br /> if (!context.InputParameters.Contains(ParameterName.Target))<br /> {<br /> return;<br /> }<br /> <br /> DynamicEntity Target = context.InputParameters[ParameterName.Target] as DynamicEntity;<br /> <br /> /* <br /> We need both regarding (parent) entity id and number of participants field <br /> Client side must Force Submit on regarding field <br /> */<br /> if ( !Target.Properties.Contains("regardingobjectid") ||<br /> !Target.Properties.Contains("gi_noofpart"))<br /> {<br /> return;<br /> }<br /> <br /> Lookup regardingObjectId = Target.Properties["regardingobjectid"] as Lookup;<br /> /* Validate that the Appointment is Regarding the Correct parent entity */<br /> if (regardingObjectId.type != "gi_custom")<br /> {<br /> return; <br /> }<br /><br /> CrmNumber noofPart = Target.Properties["gi_noofpart"] as CrmNumber;<br /> <br /> /* Validate the number of Participants */<br /> if (noofPart.Value == 0)<br /> {<br /> return;<br /> }<br /> <br /> /* Synchronize access to this code block */<br /> lock(SyncObject)<br /> {<br /> #region Retrieve all Regarding entity Appointments<br /> QueryExpression allPartQuery = new QueryExpression();<br /> allPartQuery.ColumnSet = new ColumnSet();<br /> allPartQuery.ColumnSet.AddColumn("gi_noofpart");<br /> allPartQuery.Criteria.AddCondition(<br /> "regardingobjectid" , ConditionOperator.Equal , regardingObjectId.Value<br /> );<br /> allPartQuery.Distinct = false;<br /> allPartQuery.EntityName = EntityName.appointment.ToString();<br /> <br /> RetrieveMultipleRequest retMultiRequest = new RetrieveMultipleRequest();<br /> retMultiRequest.Query = allPartQuery;<br /> retMultiRequest.ReturnDynamicEntities = true;<br /> <br /> RetrieveMultipleResponse retMultiResponse = <br /> (RetrieveMultipleResponse)context.CreateCrmService(true).Execute(retMultiRequest);<br /> <br /> #endregion<br /> <br /> #region Summaries all Appointments Number of Participants<br /> Int32 Summery = 0; <br /> foreach(DynamicEntity appointment in retMultiResponse.BusinessEntityCollection.BusinessEntities)<br /> {<br /> if (appointment.Properties.Contains("gi_noofpart"))<br /> {<br /> Summery += ((CrmNumber)appointment.Properties["gi_noofpart"]).Value; <br /> }<br /> }<br /> #endregion<br /> <br /> #region Update Parent entity Number of Participants<br /> /* Key Property */<br /> Key parentEntityKey = new Key(regardingObjectId.Value);<br /> KeyProperty parentEntityKeyProp = new KeyProperty("gi_customid", parentEntityKey);<br /> /* Number of participants Property */<br /> CrmNumberProperty noofPartProp = new CrmNumberProperty("gi_noofpart",new CrmNumber(Summery));<br /> <br /> DynamicEntity parentEntity = new DynamicEntity(regardingObjectId.type);<br /> parentEntity.Properties.Add(parentEntityKeyProp);<br /> parentEntity.Properties.Add(noofPartProp);<br /> <br /> TargetUpdateDynamic targetEntity = new TargetUpdateDynamic();<br /> targetEntity.Entity = parentEntity; <br /> UpdateRequest updateRequest = new UpdateRequest();<br /> updateRequest.Target = targetEntity;<br /> context.CreateCrmService(true).Execute(updateRequest);<br /> #endregion<br /> } <br /> }<br /> }<br />}<br /></pre>Adi Katzhttp://www.blogger.com/profile/16783428437179825705noreply@blogger.com4tag:blogger.com,1999:blog-3003801964503297388.post-59643248125070947852009-06-11T12:14:00.006+03:002010-05-05T07:52:37.448+03:00CRM 4.0 Workflow Query Wizard<div></div><br />The WQW wizard is a specialized query builder that we integrated into dynamics workflow engine. The wizard facilitates the creation of aggregate queries without the need to write custom code for each requirement that we have. This helps us create various complex workflow rules that are not available by the out of box workflow designer. A good usage example is when you need to create Monitoring / Alerting workflows or need to take some action depending on existing or non-existing amount of records that answer a specific set of conditions. <br /><div></div><br />The WQW also facilitates the creation of specific business counters on the parent entity. This is done by updating the parent entity with the WQW result using the workflow built in functionality (update record step). One of the biggest advantages of using the WQW and the business counters is that it can help you create not-in queries. <br /><div></div><br />Consider, for example, a scenario where you need to find accounts without contacts or open incidents.<br />by creating a WQW workflow step and a new account attribute (counter attribute) called number of accounts / number of open incidents you can write the WQW result to each attribute counter. This enables the user to retrieve all accounts that have 0 contacts / or 0 open incidents in each respective account counter.<br /><div></div><br />The video demonstration illustrates 2 simple scenarios that make the WQW such a wonderful workflow addition.<br />The first scenario monitors the amount of long duration outgoing calls that are made by a user. The second scenario alerts a manager when too many on-hold cases are open for a specific user. These are just examples. There is no limit on the type of Alerts or Actions that you can take using the wizard. As long as you are able to build a query around your requirement the wizard will facilitate the actions and enable you to easily create workflow rules depending on the their results.<br /><div></div><br />Another feature that the WQW has to offer is the dynamic binding of values in the current workflow context. If you take a look at the second scenario you’ll notice that the WQW uses the owner attribute dynamically. Since the owner is not known at design time the values are taken from the context at runtime and integrated into the query. <br /><div></div><br />I’m sure this addition will save you hours of tedious development effort. If you have question regarding the wizard fill free to post them here.<br />The wizard will be available on our website next week. Enjoy…<br /><div></div><br />In order to rewind right click on the flash movie and select play<br /><div></div><br /><iframe src="http://www.upsite.co.il/uploaded/files/662_161d7300581babbf835d76ad09225647.swf" width="670" height="526" ></iframe>Adi Katzhttp://www.blogger.com/profile/16783428437179825705noreply@blogger.com3tag:blogger.com,1999:blog-3003801964503297388.post-9248392165508870902009-06-10T01:03:00.011+03:002010-05-05T07:53:02.477+03:00CRM 4.0 Queue Security Manager Wizard<div></div><br /><a href="http://1.bp.blogspot.com/_M-mdv3Tfarg/Si7fk1iBJvI/AAAAAAAAAM0/Jgg1h44PpkM/s1600-h/Main.jpg"><img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 224px;border:1px solid black;" src="http://1.bp.blogspot.com/_M-mdv3Tfarg/Si7fk1iBJvI/AAAAAAAAAM0/Jgg1h44PpkM/s400/Main.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5345455631673403122" /></a><br /><div></div><br />As you know, Queues in CRM are organizational entities. This means that if the user role has read access rights on the Queue entity he can see all Queues. Organization that uses Queues as a concept usually search for a way to moderate Queue access based on Business Unit, Role and sometimes specific Users. This type of requirement is especially important for call centers and application that use queues as intermediary facilities or what I call bus stops for work that spin many users and business processes. <br /><div></div><br />Our Product also makes substantial use of Queues throughout our solution. Knowing that the way CRM handles Queues will not serve the purpose we built a wizard that enables us to define Queue visibility for any security settings. If you’re looking for a wizard like solution that enables you to control Queue access with a few clicks (No Coding Required) then you’ll love this wizard. <br /><div></div><br />The QUM wizard, as all our wizards, supports rollup4, IE8, IFD and can be installed on a 64 bit environment. <br /><div></div><br /><iframe height="502" width="670" src="http://www.upsite.co.il/uploaded/files/662_8b6bb99291f03e9c607a1ab354f9657b.swf"></iframe><br /><div></div><br />The wizard can be obtained as a stand alone product however we also included it in our security package and partner starter pack for no additional cost. <br /><div></div><br /><a href="http://www.gicrm.com/?categoryId=29264&itemId=75349">The wizard is now available on GI online website</a>Adi Katzhttp://www.blogger.com/profile/16783428437179825705noreply@blogger.com2tag:blogger.com,1999:blog-3003801964503297388.post-49588661935389358472009-05-31T01:36:00.014+03:002010-03-09T18:14:31.862+02:00CRM 4.0 Embedding User Signature in CRM Web ClientOne of the main features that the CRM email web client is missing is an automatic stationary signature. Although a user (or an administrator) can create a predefined signature and embed it before sending the email the web client requires the user to fill the TO (or CC) field in advance and then pick out the signature template using the Insert Template button. For most of us who gotten used to using advanced editors like outlook this seems like a major step backwards. <br /><br />In order to enhance the user experience and demonstrate to strength and simplicity of dynamics while I’m at it I wrote a post that automates the process. The automated signature makes use of CRM’s email template feature. Once the Global email template (signature) is in place you need to extract its id (templateid) and use it in your code. <br /><br />In order to retrieve the template id you can run this following query against the filteredtemplate view:<br /><pre class='sql' name='code'><br />SELECT TEMPLATEID FROM FILTEREDTEMPLATE WHERE TITLE = ‘USER SIGNATURE’ <br /></pre><br /><br />The nice thing about dynamics is that most UI features also have an API manifestation. In this case it’s the ability to instantiate email templates by using the InstantiateTemplateRequest. The InstantiateTemplateRequest receives a templateid, objectid and objecttype. The objectid and type are used as context so the template is able to retrieve information that is specific to the recipient entity. Since we are only interested in the user information the objectid and type are filled with the email owner which is the current user.<br /><br />Copy the following code to the email onload event and enjoy…<br /><br /><pre class='js' name='code'><br />function Signature(companyTemplateId)<br />{<br /> var sig = this;<br /> var emailIframe;<br /> var emailBody;<br /> <br /> sig.TemplateId = companyTemplateId;<br /> <br /> sig.Load = function()<br /> {<br /> try<br /> { <br /> var xml = '' + <br /> '<?xml version="1.0" encoding="utf-8"?>' + <br /> '<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">' + <br /> GenerateAuthenticationHeader() +<br /> ' <soap:Body>' + <br /> ' <Execute xmlns="http://schemas.microsoft.com/crm/2007/WebServices">' + <br /> ' <Request xsi:type="InstantiateTemplateRequest" ReturnDynamicEntities="false">' + <br /> ' <TemplateId>' + sig.TemplateId + '</TemplateId>' + <br /> ' <ObjectType>' + crmForm.ownerid.DataValue[0].typename + '</ObjectType>' + <br /> ' <ObjectId>' + crmForm.ownerid.DataValue[0].id + '</ObjectId>' + <br /> ' </Request>' + <br /> ' </Execute>' + <br /> ' </soap:Body>' + <br /> '</soap:Envelope>' + <br /> '';<br /><br /> var xmlHttpRequest = new ActiveXObject("Msxml2.XMLHTTP");<br /> xmlHttpRequest.open("POST", "/mscrmservices/2007/CrmService.asmx", false);<br /> xmlHttpRequest.setRequestHeader("SOAPAction","http://schemas.microsoft.com/crm/2007/WebServices/Execute");<br /> xmlHttpRequest.setRequestHeader("Content-Type", "text/xml; charset=utf-8");<br /> xmlHttpRequest.setRequestHeader("Content-Length", xml.length);<br /> xmlHttpRequest.send(xml);<br /> <br /> var resultXml = xmlHttpRequest.responseXML;<br /> if (xmlHttpRequest.status == 200)<br /> {<br /> emailBody = resultXml.selectSingleNode("//q1:description").text; <br /> emailIframeReady();<br /> }<br /> }<br /> catch(err)<br /> {<br /> alert(err.description);<br /> }<br /> }<br /> <br /> function emailIframeReady()<br /> {<br /> if (emailIframe.readyState != 'complete')<br /> {<br /> return;<br /> }<br /><br /> emailIframe.contentWindow.document.body.innerHTML = emailBody;<br /> } <br /> <br /> emailIframe = document.all.descriptionIFrame;<br /> emailIframe.onreadystatechange = emailIframeReady;<br />}<br /><br />function OnCrmPageLoad()<br />{<br /> if (crmForm.FormType == 1)<br /> {<br /> var signature = new Signature("90886EF8-1A4D-DE11-9CF8-0003FF230264");<br /> signature.Load();<br /> }<br />}<br /><br />OnCrmPageLoad();<br /><br /></pre>Adi Katzhttp://www.blogger.com/profile/16783428437179825705noreply@blogger.com29