Monday 26 October 2015

Associate Records with the Record of Different Entity using java script


Hi All,

As a very common requirement, I was asked to implement the functionality to associate a record in CRM 2015 just to associate the existing record to the record of different entity.

To get this work done First you need to add SDK.REST.js library to your script.

Link to download Sdk.Rest

Then copy paste this code and pass the parameter value as required.

function associateRecord (parentId, childId) {

           SDK.REST.associateRecords(
                                          parentId,                                  //Guid of parent record
                                         "new_contactlist",                       // Schema Name of Parent Entity
                                          "new_contactlist_sevaprofilenew",  //Relationship Schema Name
                                          childId,                                    // Guid of Child Record
                                          "new_sevaprofilenew",             // Schema Name of Child entity
           
                       function () {
                                        alert("Association successful.");
                                        },
                       function () {
                                      alert("Record Already Found");
                                     });
        }

To get a lookup record of parent Entity in your script .

Please refer my previous Blog
http://crmpankaj.blogspot.in/2015/10/create-custom-dialog-lookup-values-for.html

Hope this would be very helpful to you in your development.

Create a custom Dialog Lookup Records For an Entities on button click.

One feature of Dialogs is the ability to prompt the user for a record to interact with i.e. prompt for a lookup response.

This blog fulfil the Requirement Like we have a custom Button on the Form/Ribbon and onclick of this button i need to create a lookup for an Entity which looks similar to CRM Lookup.

Here is the code which i have used to get the solution.


var url = "/_controls/lookup/lookupsingle.aspx?objecttypes=" + objectTypeCode;
var DialogOptions = new Xrm.DialogOptions();
DialogOptions.width = 500;
 DialogOptions.height = 300;
Xrm.Internal.openDialog(Mscrm.CrmUri.create(url).toString(), DialogOptions, null, null, returnDialogResponse);

objectTypeCode:- You Need to provide a objectTypecode value of the Entity on which Entity the lookup is going to be created But I Recommend to get the "objectTypecode" dynamically by passing Schema Name of the Entity because when the solution is Export/Import then this Entity objectTypeCode may differ from different Machine.

Here i am providing a method which help you to get the objectTypeCode of an Entity by passing the Schema Name of an Entity.

 function getEntityObjectTypeCodeByName(entitySchemaName) {

            try {
                var lookupService = new window.parent.RemoteCommand("LookupService",                                           "RetrieveTypeCode");

                lookupService.SetParameter("entityName", entityName);

                var result = lookupService.Execute();

                if (result.Success && typeof result.ReturnValue == "number") {

                    return result.ReturnValue;

                } else {
                    return null;
                }
            } 
          catch (e) {
                alert("Error getting ETC by Name – " + e.description);
            }
        }

Hope this will be Helpful in your CRM custom development.



Wednesday 15 July 2015

CRM 2015: JavaScript – Lookup Filtering using addCustomFilter


Here is my new post with the new java scripts in CRM for filtering lookup. In this post I am going to describe how to use addCustomView function to filter the lookup value.


Below I will show you how to filter a lookup based on the value of another field on the form. In this scenario we will be using the LookupField1 to filter the Parent Account lookup to only display Accounts with a matching LookupField1 value, and to display all Accounts when no LookupField1 value is specified.

To filter this we use the following code, and call the “getFilteredLookup” function on load and onChange of "LookupField1" of the form.

Click on the Image to Enlarge....



To create a fetchXml best way is to go and create an Advanced Find in CRM according to your condition and download the fetchXml.

After that you need to write an layoutXml for new lookup .For this i suggest copy the above code which i have written and change the row "id" and cell "name".

For viewId just provide any "id"({00000000-0000-0000-0000-000000000001}) as u like in above format and make sure it doesn't match with your default viewId.

Hope this would be helpfull to you.
Enjoy the great technology CRM.  Good Luck




Thursday 9 July 2015

Not Able To Register Custom WorkFlow In Dynamic CRM 2013

When i was trying to register my Custom Work Flow using CRM SDK 2013 version 6.1.1 .I used to get Error that  "No plugins have been selected from the list"

I have added a screen shot bottom which clearly make us understand that what we are missing.


If you are looking for this problem then Solution is that you need to download the older version 
of the SDK 2013 version 6.1.0 v2 and then register your workflow with the plugin registration
tool available in tools Folder.                                                                                                     

To get the older version of SDK. I found a link from community.dynamics.com shared by 
Guido Preite  in his blog .                                                                                                                         
                                                                                                                          
 Use this Link  :::::::                                                                                                                                      https://onedrive.live.com/redir? resid=E4B83260B94D4158!1387&authkey=!ALuzupR9uXK3iII&ithint=folder%2c.exe           

Hope this will be helpfull to you in your development work and will save your time.