Search This Blog

Showing posts with label Dynamics CRM. Show all posts
Showing posts with label Dynamics CRM. Show all posts

Wednesday, July 12, 2017

Enable and Disable controls inside a tab


 Enable / Disable a Section

function sectiondisable(sectionname, disablestatus) {
    var ctrlName = Xrm.Page.ui.controls.get();
    for (var i in ctrlName) {
        var ctrl = ctrlName[i];
        if (ctrl.getParent() == null)
            continue;
        var ctrlSection = ctrl.getParent().getName();
        if (ctrlSection == sectionname) {
            ctrl.setDisabled(disablestatus);
        }
    }
}


 Enable / Disable a Tab
function tabdisable(tabname, disablestatus) {
    var tab = Xrm.Page.ui.tabs.get(tabname);
    if (tab == null)
        return;
    else {
        var tabsections = tab.sections.get();
        for (var i in tabsections) {
            var secname = tabsections[i].getName();
            sectiondisable(secname, disablestatus);
        }
    }
}

Friday, June 23, 2017

Click phone number in CRM automatically call go in Skype or Skype for Business

Click phone number in CRM automatically call go in Skype or Skype for Business
Whenever click the skype icon or phone number, we want to call automatically through skype for business or skype.




There are two ways we could achieve it
1)Default CRM method call
2)Using javascript

1) Default CRM method call

Code:

Mscrm.Shortcuts.openPhoneWindow('789-852-987','+1','true');

Output:


 Behind the code  "Mscrm.Shortcuts.openPhoneWindow" in CRM

openPhoneWindow = function (phoneNumber, countryCode, useSkypeProtocol) {
    var $v_0 = "tel";
    $v_1 = (new parent.Mscrm.PhoneUriBuilder).buildUri(phoneNumber, countryCode, $v_0),
    $v_2 = parent.Mscrm.CrmUri.createForOrganization($v_1, null);
    $v_2.checkParamsNoEqual = true;
    safeWindowOpen($v_2, "", "")
};
function safeWindowOpen(url, name, features, replace, disablePopupWarning) {
    var $v_0 = null;
    //if (!IsNull(url))
    $v_0 = url.toString();
    //  else $v_0 = "";
    //if (IsNull(features))
    features = "";
    parent.Mscrm.PerformanceTracing.write("Navigate", $v_0);
    var $v_1 = null;
    try {
        if (parent.Mscrm.CrmWindow.$3C && parent.Mscrm.Utilities.isChrome()) features = $7x(features, "status=1");
        parent.Mscrm.CrmWindow.$3C = true;
        var $v_2 = new Date;
        if (window.name === name)
            //The below line of code only open skype window.....
            $v_1 = parent.masterWindow().open($v_0, name, features, replace);
        else
            $v_1 = window.open($v_0, name, features, replace);
        attachErrorHandler($v_1);
        try {
            $v_1.focus()
        } catch (e) { }
        var $v_3 = new Date;
        $9p($v_1, $v_2.getTime(), $v_3.getTime());
        $v_1._masterWindow = masterWindow()
    } catch ($$e_9) { }
    //IsNull($v_1) && !disablePopupWarning && handlePopupBlockerError($v_0);
    return $v_1
}

function Test() {
    openPhoneWindow("768-555-0156", "+91", "false")
}
 

2) Using Javascript:

Code:

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
</head>
    <script type="text/javascript" src="http://www.skypeassets.com/i/scom/js/skype-uri.js"></script>
<body>
    <a href="tel:23456789">Call</a>
</body>
</html>

Output:



Monday, January 2, 2017

Increase Dynamics CRM Logout timout



  • Open the windows powershell in the adminsitrator mode.Type the below command

Get-ADFSRelyingPartyTrust -Name "relying_party"

Where you replace the “relying_party” with the name you identified in




  • In our case the command will be: 

Get-ADFSRelyingPartyTrust -Name “CRM IFD Relying Party


  • The command to set the time you want to set for Auto Logout.

Set-ADFSRelyingPartyTrust -Targetname “CRM IFD Relying Party“ -TokenLifetime 720

Note: The 720 is time in minutes. 12 Hours in this case. You can change the value up and down as liked

Thanks to https://www.interactivewebs.com/blog/index.php/server-tips/crm-2015-extend-auto-logout-time-in-ifd/

Thursday, December 15, 2016

Convert OptionSet to MultiSelect checkboxes in CRM


  • Create two fields to store optionset value and text
  • Create html webresource with below source code.

<html>
<head>
    <title></title>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
    <script type="text/javascript">

        $(document).ready(function () {
            ConvertDropDownToCheckBox();
        });

        //Coverts option list to checkbox
        function ConvertDropDownToCheckBox() {

            var _optionSet = parent.Xrm.Page.getAttribute("new_optionSet").getOptions();
            var _optionSetValue = parent.Xrm.Page.getAttribute("address1_line1").getValue();

            $(_optionSet).each(function (i, e) {

                var _text = $(this)[0].text;
                var _value = $(this)[0].value;
                var _isChecked = false;
                if (_text !== '') {
                    if (_optionSetValue !== null && _optionSetValue.indexOf(_value) !== -1)
                        _isChecked = true;

                    var _checkbox = "<input type='checkbox' name='" + _value + "'/>";
                    $(_checkbox)
                        .attr("value", _value)
                        .attr("checked", _isChecked)
                        .attr("id", "id" + _value)
                        .click(function () {

                            //To Set Picklist Select Values
                            var selectedOption = parent.Xrm.Page.getAttribute("address1_line1").getValue();
                            if (this.checked) {
                                if (selectedOption === null)
                                    selectedOption = _value;
                                else {
                                    var temp = selectedOption.indexOf(",") !== -1 ? selectedOption.split(',') : selectedOption.split(' ');
                                    temp.push(_value);
                                    selectedOption = temp.join();
                                }
                            }
                            else {
                                if (selectedOption.indexOf(_value) !== -1) {
                                    var temp = selectedOption.indexOf(",") !== -1 ? selectedOption.split(',') : selectedOption.split(' ');
                                    temp = removeArrayElement(temp, _value);
                                    selectedOption = temp.join();
                                }
                                else
                                    selectedOption = selectedOption.replace(_value, "");
                            }
                            parent.Xrm.Page.getAttribute("address1_line1").setValue(selectedOption.toString());


                            //To Set Picklist Select Text
                            var _selectedText = parent.Xrm.Page.getAttribute("address1_line2").getValue();
                            if (this.checked) {
                                if (_selectedText === null)
                                    _selectedText = _text;
                                else {
                                    var temp = _selectedText.indexOf(',') !== -1 ? _selectedText.split(',') : _selectedText.split(' ');
                                    temp.push(_text);
                                    _selectedText = temp.join();
                                }
                            }
                            else {
                                if (_selectedText.indexOf(_text) != -1) {
                                    var temp = _selectedText.indexOf(',') !== -1 ? _selectedText.split(',') : _selectedText.split(' ');
                                    temp = removeArrayElement(temp, _text);
                                    _selectedText = temp.join();
                                }
                                else
                                    _selectedText = _selectedText.replace(_text, "");
                            }
                            parent.Xrm.Page.getAttribute("address1_line2").setValue(_selectedText);

                        }).appendTo(checkBoxContainer);
                }


                //add label to the checkbox
                $("<label for='" + _value + "'>" + _text + "</label>").appendTo(checkBoxContainer);
            });
        }


        function removeArrayElement(arr) {
            var what, a = arguments, L = a.length, ax;
            while (L > 1 && arr.length) {
                what = a[--L];
                while ((ax = arr.indexOf(what.toString())) != -1) {
                    arr.splice(ax, 1);
                }
            }
            return arr;
        }

    </script>
</head>
<body>

    <div id="checkBoxContainer">
    </div>

</body>
</html>

Please refer
https://community.dynamics.com/crm/f/117/t/211615

Lookup Control value set in CRM using Javascript

Lookup Control value set in CRM using Javascript

  var objPaymentModeValue = [{
        id: result[0].new_PaymentModeId.Id,
        name: result[0].new_PaymentModeId.Name,
        entityType: 'new_paymentmode'
    }];

 Xrm.Page.getAttribute("new_paymentmodeid").setValue(objPaymentModeValue);

CRM Form Load Performance

CRM Form Load Performance
Open the CRM on-premises and online in internet explorer.Click ctrl+shift+e

Append vs Append To

Append and Append To basically deal with the entities that are parties to a 1:N relationship or N:1 relationship.

Append: When an entity has the lookup of another entity on its form. It is important that the user have the “Append” privilege on this entity so that it can set the values for the lookups on this entity. For eg: Contact has the lookup of Account on its form so here the user needs to have the “Append” privilege to be able to set the parent account.

Append To: When an entity is available as a lookup on another entity form. It is important that the user have the “Append to” privilege on the entity that is referred to in the lookup so that it can set the values for the lookups of this entity on any other form. For eg: Account has the lookup of primary contact. So here the user needs to have the “Append To” privilege to be able to set the Primary Contact for the Account.

Wednesday, October 12, 2016

Different values with Date() in Chrome and IE

Different values with Date() in Chrome and IE

IE

Chrome



It is a bug in the ECMAScript 5.1 spec https://bugs.ecmascript.org/show_bug.cgi?id=112. From the comments on the bug, it appears that Chrome 35 implements what the spec says (literally), while IE 10 implements what the spec actually intended to say.
The bug relates to the same sentence in the spec mentioned in the question:
ECMA-262 edition 5.1 (p. 179): The value of an of absent time zone offset is "Z".
The draft version ECMAScript 6 (http://people.mozilla.org/~jorendorff/es6-draft.html) changes this sentence to:
If the time zone offset is absent, the date-time is interpreted as a local time.

Monday, September 12, 2016

Activity point type code in dynamics CRM

Activity point type code in dynamics CRM 

Value
Label
4201
Appointment
4202
Email
4204
Fax
4206
Case Resolution
4207
Letter
4208
Opportunity Close
4209
Order Close
4210
Phone Call
4211
Quote Close
4212
Task
4214
Service Activity
4251
Recurring Appointment
4401
Campaign Response
4402
Campaign Activity
4406
Bulk Operation

Friday, August 19, 2016

How Date time with time zone works in CRM

How Date time with time zone works in CRM


  • DateTime is saved in database as UTC time
  • DateTime queried directly from SQL table or base view returns UTC

  • DateTime in CRM UI is always shown based on user’s local time zone.



  • DateTime queried from filtered view returns users local time

Thursday, August 18, 2016

Change default base currency in CRM 2011

  1. Open Microsoft SQL Server Management Studio and connect to the SQL server hosting your CRM database.
  2. Find database with name [YourCompanyName]_MSCRM
  3. Backup that database!
  4. Open table [dbo].[TransactionCurrencyBase]
  5. The existing base currency is the first row. Ensure the target currency is there.
  6. Open table [dbo].[OrganizationBase] for edit. Find your organization there, most likely there will be just one row.
  7. Change CurrencySymbol, BaseISOCurrencyCode, BaseCurrencySymbol and BaseCurrencyId. The last field’s value you should take from TransactionCurrencyBase table, from the TransactionCurrencyId field.
That’s it. One thing you should bear in mind – if the conversion rate to base currency was used somewhere, the numbers may become incorrect. Like, if the sum was meant in base currency, but the base currency changed without recalculation.

Tuesday, August 2, 2016

OData value get or set in CRM CRUD operation

OData Update: 

var objEntity =new Object();
Lookup:
 objEntity.RegardingObjectId =
    {
        Id: entityId,
        LogicalName: "incident",
        Name: subject
    };
Currency:
var objTotalValue = parseFloat(TotalValue);
 objEntity.QuoteTotalAmount =
    {
        Value: objTotalValue.toString()
    };
OptionSet:

var objTotalValue = 3;//OptionSet value not name
 objEntity.CustomerTypeCode=
    {
        Value: objTotalValue
    };
DateTime:
var dtDateTime= Xrm.Page.getAttribute('kti_datecheck').getValue();
//kti_datecheckvalue is a datetime control

 objEntity.kti_DateCheck=dtDateTime;
    
TwoOptions:

//kti_bIsAccountAddress is a twoOption date type control 
objEntity.kti_bIsAccountAddress=true;//value=false or true
OData Read:

Lookup:
var dGuid=Xrm.Page.data.entity.getId();
//Filter customer record in the contact 
var strFilter=$filter=ParentCustomerId/Id eq guid'"+dGuid+"'";
Currency:
//Credit limit is currency data type control 
var strFilter=$filter=CreditLimit/Value eq 1000;
DateTime:
var dtDateTime= Xrm.Page.getAttribute('kti_datecheck').getValue();
//kti_datecheckvalue is a datetime control

var strFilter=$filter=kti_DateCheck eq datetime'"+dtDateTime.toJSON()+"'";

//because ODate value filter supports universal format 2016-08-02T19:05:37Z
    
Option Set:
//Family status code is optionset data type control(value mention in the field) 
var strFilter=$filter=FamilyStatusCode/Value eq 3;
Two Option:


//Credit hold is two option data type control(value either true or false) 
var strFilter=$filter=CreditOnHold eq true;
Filter Guid:

//Credit hold is two option data type control(value either true or false) 
var strFilter=$filter=accountId  eq guid'37cd7ab5-a9ee-e611-80e8-3863bb34de80';

Filter Multiple Guid:

//Credit hold is two option data type control(value either true or false) 
var strFilter=$filter=accountId eq guid'37cd7ab5-a9ee-e611-80e8-3863bb34de80' or accountId eq guid'19b02e31-b4ef-e611-80e8-3863bb34de80' ;

Friday, July 22, 2016

Product Bundle in Dynamics CRM

Product Bundle in Dynamics CRM

Product Bundles allow organizations to bundle products and assign specific pricing for that bundle. Once the bundle is added to an opportunity, quote, or order, the sales person can simply adjust the quantities of the products within the bundle, and the pricing will be calculated accordingly.


We are going to create two product and add two product in a bundle. We are going to create two bundle and will explain how bundle will work differently

Product name:



  1. Dell Laptop
  2. Dell Mouse

Bundle name:


  1. Dell Offer Laptop(Option bundle product)
  2. Dell Offer Laptop(Required bundle product)
Explanation:


  • Create a product as "Dell Laptop" and "Dell Mouse" with price list item. I hope folks, you knows how to create a product.




  • Create a bundle as "Dell Offer Laptop(Required)". Click Add bundle in the ribbon.







  • In the bundle there is a section "Bundle-Product". We are going to bundle two product "Dell Laptop" and "Dell Mouse". 


                                   
  • In the Bundle product there is a field called "Required" based on this field total amount calculation is calculated in quote.



                               

  • Add price list item to the bundle


  • Create a another bundle and add two product in the bundle product but in the bundle product required field is set to "required" and add price list item.



  • Now let us see how bundle will work differently for that i am going to create two quote. In the first quote I am going to add first bundle that set bundle product required field set as option and in the second quote going to add second bundle.



  • In the bundle  that set bundle product required field set as option you see "price per unit" is filled with corresponding price and total amount is calculated by





Total Amount in quote =Product bundle price + product price

Product bundle price defined in the price list item as 1000
Dell Laptop Product price defined in the price list item as 1000
Dell Mouse Product price defined in the price list item as 500
Eg
Total Amount in quote =1000 +1000+500=2500



  • In second quote bundle  that set bundle product required field set as required you see "price per unit" is filled as "0" and total amount is calculated by





Total Amount in quote =Product bundle price 
Product bundle price defined in the price list item as 1000

Eg
Total Amount in quote =1000




Product Bundle in Dynamics CRM

Product Bundle in Dynamics CRM

Product Bundles allow organizations to bundle products and assign specific pricing for that bundle. Once the bundle is added to an opportunity, quote, or order, the sales person can simply adjust the quantities of the products within the bundle, and the pricing will be calculated accordingly.


We are going to create two product and add two product in a bundle. We are going to create two bundle and will explain how bundle will work differently

Product name:


  1. Dell Laptop
  2. Dell Mouse

Bundle name:

  1. Dell Offer Laptop(Option bundle product)
  2. Dell Offer Laptop(Required bundle product)
Explanation:

  • Create a product as "Dell Laptop" and "Dell Mouse" with price list item. I hope folks, you knows how to create a product.


  • Create a bundle as "Dell Offer Laptop(Required)". Click Add bundle in the ribbon.




  • In the bundle there is a section "Bundle-Product". We are going to bundle two product "Dell Laptop" and "Dell Mouse". 

                                   
  • In the Bundle product there is a field called "Required" based on this field total amount calculation is calculated in quote.


                               

  • Add price list item to the bundle

  • Create a another bundle and add two product in the bundle product but in the bundle product required field is set to "required" and add price list item.


  • Now let us see how bundle will work differently for that i am going to create two quote. In the first quote I am going to add first bundle that set bundle product required field set as option and in the second quote going to add second bundle.


  • In the bundle  that set bundle product required field set as option you see "price per unit" is filled with corresponding price and total amount is calculated by



Total Amount in quote =Product bundle price + product price

Product bundle price defined in the price list item as 1000
Dell Laptop Product price defined in the price list item as 1000
Dell Mouse Product price defined in the price list item as 500
Eg
Total Amount in quote =1000 +1000+500=2500


  • In second quote bundle  that set bundle product required field set as required you see "price per unit" is filled as "0" and total amount is calculated by



Total Amount in quote =Product bundle price 
Product bundle price defined in the price list item as 1000

Eg
Total Amount in quote =1000