Showing posts with label Hot fix. Show all posts
Showing posts with label Hot fix. Show all posts

Apr 29, 2019

SSIS Connections cannot be changed

This a quite common issue you would come across, especially if you want to change the Data Source  of a SSIS Package and check some functionality against a different data source. Issue is, how many times you change it from Connection Manager (ex. Server Name), it jumps back to the previous value.

Reason behind this behavior is these details are associated with Parameters and sometimes it may be not present in the view.

You can right click the Project.params and view the code in such cases as shown below;


Now inspect the code;


You will realize that previous details (ex. Server) are set as shown above and they doesn't get change when you change the Connection Manager from UI. So you need to change this file with new details. This fix the issue.

Mar 9, 2018

Cannot Delete Entity – Invisible Form Dependency

Once we remove all the possible dependencies for an Entity, we are allowed to Delete it in Dynamics 365. Once in a while it doesn’t behave as expected. I faced one such case recently.  Though I removed every possible/visible dependency, I couldn’t delete the Entity (say Region, new_region). It shows me some more Form dependencies.

In such case, what you need to do is create a Temporary Solution and add only the Entity that Form belongs to, Import it, Unzip and Open Customization.xml in readable editor. Now search for the Entity Schema name (i.e. new_region) you need to delete. Most probably, you will find section like below.


Explanation
This means dependency is on one of the Filter of lookup fields within that Form. If you browse to the customisation of that Form you will see particular Lookup Filter is not even enable. My hunch is, previously this Lookup filter may have been configured to filter by the relationship with the entity we are going to delete. This <DependentAttributeType> tag may not have been removed once disabling the Filter of the lookup or even when deleting the relationship.

How to Fix
Enable the Lookup filter and set a different filed (ex. By Owner) and publish. Then this troublesome tag will be replaced with this new type. Now we can delete our Entity. Now you can disable the Filtered lookup as necessary.

Dec 13, 2017

Get Form Type in Business Rules

There is no proper way of identify if form is in CREATE or UPDATE. This seems a big missing piece when it comes to implement field functionalities especially for Form Scopes.

Dynamics 365 (Version 8.2 or earlier)

One passive way of doing that is to check if Create On field contains data.

1) Created On - Not Null - Update
2) Created On - Null - Create

Using Create On is particularly sensible since that field is not set with on Load event even by chance.



Dynamics 365 (Version 9)

Then I realise above solution does't work for Version 9. Then found a way to do it slightly differently.

Instead of Created On, we have select a required field to check value to decide if its created or not.

Suppose we need to lock the Department field of Contact after creation.

1) Set Department field as Read-Only in the form.
2) Now do the Business Rule using one of the Required Fields such as First Name.
                                                                               

Feb 26, 2015

Issue with datetime formats in OData retrievals

We now use OData Service for client side data retrievals. Yet, there is a bit of complexity when dealing with date time fields.  I usually use REST methods of XrmServiceToolkit library. When I try to retrieve datetime field and populate in some form field, I simply couldn’t do since what I retrieved was something different. Something like “/Date(1420588331000)/”. What is this?

This is a time encoded to a single integer which increases every second. This is UNIX timestamp. Though this is a logical representation of time which can be very helpful when dealing with complex time calculations, in our operation this can be frustrating.

We need to transfer this to date time which can be identified by JavaScript. So below code snippet can be helpful.

//Method

dateFormatUnixStamp: function (_uString) {
    var _date = null;
    if (_uString != null) {
        _date = new Date(parseInt(_uString.slice(_uString.indexOf("(") + 1, _uString.indexOf(")"))));
        _date.setDate(_date.getDate());
    }
    return _date;
}

//Calling

//Suppose _Ent is a entity we retrived through the service
//and we are assigning it to new_startdate of current form

var _startDate = dateFormatUnixStamp(_Ent.new_StartDate);
Xrm.Page.getAttribute(new_startdate).setValue(_startDate);

These two blogs also provides much helpful code samples in this regards;

https://rajeevpentyala.wordpress.com/2011/08/21/read-odata-service-date-field-in-crm-2011/
http://blogs.catapultsystems.com/rhutton/archive/2014/01/30/crm-2013-handling-odata-date-field-value.aspx

Thank you Deepak Mehta for the help.

Jun 25, 2014

Issue in setFocus in forms of CRM 2011

After spending some frustrating time I found a native CRM 2011 issue. When I try to set focus to a lookup field onload of form, it just doesnt work.

What I observed was it jumps to the expected field, but switches back to some other field in the top of the form in no time.

Then I found below fix.. thought of sharing here;

function onLoad() {
   window.setTimeout(focusFromField,100)
}

function focusFromField() {
  var _Control = Xrm.Page.ui.controls.get("new_officeid");
  _Control.setFocus();
}

Also learned this issue is fixed in CRM 2013.

Jun 17, 2014

Resolution for issue of wrong totals in tables grouped with filters in SSRS

Previous post I explained the fruit you can have by using filters when grouping table columns. Still, it can be frustrating if you need subtotals for any numeric values in table. What really happens is totals ignore the filters. (Just behave like there is no filter!)

Suppose we add group by some field, but only needs values for given two countries. (i.e. France and Belgium). Filter will be seen as below;


So we also need to get sub totals for groups (suppose, field name as revenueVal). So what we usually do is put below method in the total row;

SUM(revenueVal)

As I explained, issue is this will sum up all the revenues of all the countries not just for filtered ones.

This is the resolution.
Define another calculated field in the DataSet.


And add the same filter criteria as an expression;


Expression will be looked like this… hope you understand the simple logic. We are replacing zero for all the rows which do not meet the criteria.

* Note: If you are going to use the totals in Matrix (instead of a table) please use “nothing” instead of “0” in above expression.

Now we are using our own calculated field for calculation; 

SUM(revenueVal_Filtered)

Now this subtotal adheres our criteria.

Jun 25, 2013

Issues of using checkbox in CRM 2011

In a previous post I explained difference of using onChange and onClick in CRM 4.0

Now it has come the time to talk the same thing against CRM 2011. As same as 4.0, even in CRM 2011 we got only the onChange in native manner. As we all know the problem is you need to click somewhere else after clicking the checkbox to execute the event.  So we need to implement onClick to accomplish this. It is bit similar to  4.0, but there is a complication.

For some crazy reason, standard Xrm model that works for 2011 doesn’t work here and have to use the 4.0 style code. Other issue is execution take cyclic pattern and our code gets executed twice! So we need to change the focus as soon as we finish the code. Please check the working code (this should go in onload event);

MyCheckbox = function()
{
    crmForm.all.new_sample.onclick = function()
    {
       //Code
       //Change focus to another field  
    }
}

Issues are not finish yet! Practically, we might need to do something according to the value of the relevant check box. Biggest confusion comes here. Values given are completely opposite. When you check the checkbox you might get false instead of true and vice versa. Why this happens?

I am trying to understand it this way. (please correct me If I am wrong) This is not an error. We are executing the code on “click”. This doesn’t mean we have changed the value in the time we execute the code. Of course what we see is the "changed" situation through the form. Actually code happens for previous value of the check box. I think this is the reason Microsoft doesn’t provide this event in their native framework.

If we understand this, we are good to proceed with our work without any trouble. Only thing is do the opposite when playing around with the value of the checkbox upon onClick.

var _checkbox = Xrm.Page.getAttribute("new_sample").getValue();
if (_checkbox == true)
{ 
  //code for false 
}
else
{
  //code for true 
}

This is bit confusing.. but manageable.

Mar 14, 2013

Sales process – Part 3 – Modifying calculation of quote product

A couple of previous posts explained the standard way of working with quotations and its level of flexibility. In rare cases, it could need you to modify the standard calculations. In this article, we will analyse options and constrains of doing such tasks in Quote product. Most popular requirement that would come your way could be implementing automated tax (or GST) system. Natively TAX is just an editable field in quote product.

Consider the pricing pane of the quote product form.


Three fields I put within the green squares are editable fields. These are the editable fields with their schema names and types.

Name
Schema Name
Type
Quantity
quantity
Decimal
Manual Discount
manualdiscountamount
Currency
Tax
tax
Currency

These are the field that can’t be edited with their schema names and types.

Name
Schema Name
Type
Price per unit
priceperunit
Currency
Volume Discount
volumediscountamount
Currency
Amount
baseamount
Currency
Extended Amount
extendedamount
Currency

Considerations for plug-in development

Obviously we need to develop our own plug-ins to enhance/modify the current calculations. Now consider my research result on plugin behaviour in this regard.

 
Create
Update
Pre stage
Post stage
Pre stage
Post stage
Editable fields
(of first table)
Available, can modify
Available, can modify
Modified field available and others can be retrieved, can modify *
Modified field available and others can be retrieved, can modify*
Other field
(of second table)
Not available, cannot modify
Not available, cannot modify
Can be retrieved, cannot modify.
Can be retrieved, cannot modify.
* If you modify the same entity in Update event make sure you avoid infinite loops.

Essence of this result is we can only play around with Quantity, Manual Discount and Tax. Good news is any time you change those fields; calculations are done accordingly to newly changed values of those fields. In other terms “Extended amount” get the correct value regardless of where you change those fields.

It implies CRM does its own calculations after the plug-in engine has completed its performances. In fact, you should not/ cannot amend other fields such as Price per Unit, Volume Discount, Amount and Extended Amount.

Some points to think

1) If you want to introduce an auto tax calculation method, it’s possible. Better have the logic for both create and modify event plug-ins.

2) If you consider the fact that we have two fields (namely Tax and Manual discount) to play around; tax is being added and Manual discount is being subtracted from total automatically. So whatever the additions and subtractions you need can be pushed to the current calculation mechanism if you are creative enough. Think a bit.

3) There is a chance your logic needs fields which are unavailable in plug-in context such as Price per Unit, Volume Discount and Amount. In that case, you are still able to retrieve first two fields from Price List and Discount List entities respectively and Calculate Amount. Read my 1st and 2nd parts of this article for better understanding.

4) One would also think of give up the native total fields and introduce new custom fields, WHICH IS NOT RECOMMONDED AT ALL. This means you are rewriting your own calculation logic for entire quoting including quote product and quote. That will also push you to introduce your own recalculation button in Quote header. Also you are again facing problems when quote values are transferred to Order entity in a later stage. Personally, I don’t see any reason to go in to this mess.

1st part of this article: Sales process – Part 1 – Product Catalog
2nd part of this article: Sales process – Part 2 – Quoting
4th part of this article: Sales process – Part 4 – Modifying calculation of quote

Oct 4, 2012

Advanced find – Select all the records of all the pages

Ribbon of advanced find result view

 
Ribbon of the result pane of advanced find view is same as Subgrid ribbon. Yep it is! So whatever the ribbon modifications you do with the format of  “Mscrm.SubGrid.<entityname>” is being applied for this ribbon. So you are free to do anything with any custom button by executing a Javascript as I explained in my previous post. Check it here.

Now we know, we can pass different parameters to our method, but obviously, favourite would be the passing of Ids of selected records. So we are good to do any operation for those records.

Reading the current grid VS reading the full result set

Anyway, none of these parameters leads us to read all the records of all the pages of the result. Our operations are restricted to current grid. Current grid could hold maximum records of 250, with least 25, depending on your settings.


If our result consists of more records and we need to do a batch operation for all of them we are not helped. One approach would be to save the view after selecting the criteria and again read the relevant fetch from SavedQueryBase. Problem of this approach is one has to save it manually with a predetermined name. (Name is to be used when querying by the programme)

Now this is a way of reading the relevant Fetch XML without saving, from the result pane. I urge this is an unsupported method, but it works.

var _XML = document.getElementById("fetchXml");
alert(_XML.value);

Now we have the fetch used to read the data for advanced find, so we are ready to do any operation for entire result set.

Jul 16, 2012

Script error of Follow up button

When clicking the Follow up button, sometimes users see a script error as by the bottom left of corner of the browser.


This occurs since your form assistant is disabled. Obviously, this is a contradiction.  Follow up pane should get loaded in form assistant section, which is not available.

Form Assistant and Follow up
So, when you design the form, you have to think Follow up functionality together with form assistant.

1) Option 1: If you want follow up, your form assistant should be enabled
For this, go to customizations > Open relevant entity > click Forms and Views > Open Form > Open Form prosperities > Click display tab.
Then enable the Form assistant by clicking the check box.


2) Option 2: If you want form assistant to be disabled, follow up button should be removed
How to remove the button using JavaScript is discussed here.

Decide this in terms of your useability expectations.

Jul 22, 2011

Issue of reading parent entity from create form in CRM 2011

In CRM 2011, reading the parent fields from child form has a trick. For example, if you are reading a quote field while you are in quote product should be done carefully. Usually, it’s advised to do as follows;

var pageParent = window.top.opener.parent.Xrm.Page;
var preantName = pageParent.getAttribute("Name").getValue();

This doesn’t work for create forms, but Update forms! So you are required to do something like this to read from Create forms..

var preantName = window.parent.opener.crmForm.all.name.DataValue;

When I come across this, I simply wrote below method which worked for me. This handles both Create and Update form types for you. May be this can’t be the best code, but I couldn’t find a better code in the web.

function ReturnParentField(_fieldName)
{
 var FORM_TYPE_CREATE = 1;
 var FORM_TYPE_UPDATE = 2;
  
 var formType = Xrm.Page.ui.getFormType();
 var _pageParent = window.top.opener.parent.Xrm.Page;
 var _value = null;

 if (formType==FORM_TYPE_CREATE)
 {
   if (eval('window.parent.opener.crmForm.all.'+_fieldName+'.DataValue') != null)
   {
    _value = eval('window.parent.opener.crmForm.all.'+_fieldName+'.DataValue');
   }
  }
  else if (_pageParent != null)
  {
    if (_pageParent.data != null)
    {
       if (eval('_pageParent.getAttribute("'+_fieldName+'").getValue()') != null)
       {
           _value = eval('_pageParent.getAttribute("'+_fieldName+'").getValue()');
       }
     }
     else
     {
       _value = eval('window.parent.opener.crmForm.all.'+_fieldName+'.DataValue');
     }
   }
   return _value;
}

When you go through this code, you will see some complexity in the later stage when I have made it handle two ways for update form. That’s because, when you access existing record from usual associate view (_pageParent.data != null) and its possible to use getAttribute() method accordingly. In CRM 2011 contains new feature of accessing the associate records (or child records) within the form area called sub-grids which doesn’t work like this. It contained no attributes to read. Luckily, it again enables you to read parent information in most traditional way, which we have used in Create form type.

Hope this will help.

Jun 20, 2011

OnChange() event of CheckBox of CRM 4.0

OnChange() event of the CheckBoxes done in the forms of CRM 4.0 is not fired the way it should be. Ironically you can see specific place to write the code and enable the event according to usual CRM concept.

Anyway, it is easy to write the same thing (actually onClick) in onLoad form and get the thing done. Write the even function in the onload as mentioned below.

MyDemoCheckbox = function()
{
    crmForm.all.new_mydemocheckbox.onclick = function() 
    {
       //Do what you need
    }
}

Hope this will work for you.

Please check newest post on this topic.

Jun 19, 2011

Two default public views?

This is something you don’t see usually in Dynamics CRM 4.0. According to picture, it shows two default public view, which is against the norms. Surprisingly, this can happen rarely in CRM systems. This is unexplained.


What you have to do is, export the customization of particular entity and check for sections related to public views (Here I am strictly calling “Public” views; I want you to omit the Associate views, advanced find views and etc.) and find <isdefault name="Yes">1</isdefault> tag. You will find this for more than one Public View. You will have to change them to <isdefault name="No">0</isdefault>, except for the correct default public view.

Now import the customization and publish. You problem is solved.