Home » Microsoft Technologies

Matching two different entity records


I have a requirement where i need to compare some fields from Lead entity to some fields from other custom entity i.e., if i take a Lead and try to match it with other custom entity i need to able to retrieve all the custom entity records that match with the Lead. The comparison will be performed based on some fields like email, telephone, etc. Do we have any tool that allows us to perform such action?


Many Thanks


4 Answers Found


Answer 1

The Duplicate Detection feature allows you to compare fields from different entities, but only for the purposes of duplicate detection. If you need to compare two different entities for some other purpose, you'll need to write some custom code. How you design and implement the code will depend on the purpose of the comparison.



Answer 2


Do we have any third party tool that performs the comparison in more intelligent way rather than string comparison. I mean John Smith and Jhon Smith should be treated as same (John typed wrong as Jhon in other case). 


And also duplicate detection feature will allow to compare records of only one type of entity, in this case we need to compare records of one entity with records of other entity. 


Answer 3

A agree with Neil as we will have to tell the system about all the possible combinations otherwise it would judge.

1. An easier appoarch will be to have a report to compare all similiar record.

2. An ifame or web page showing all similar records of other entity using LIKE operator in fetch statement.


Answer 4

You can check the Dynamics Marketplace for any Apps that might be available to perform this function. 


Hello. I am creating a login/logoff audit program to track / restrict users on our network.

I have a table containing log on/off records so : loginid, userid, logindatetime, state, computername (state is either: 1 logon, -1 logoff or 0 attempted logon)

its probably quite simple but i can't quite get my head around it, i need a query to tell me who is currently logged on, ie the most recent logon (state=1) which has no logoff (state=-1) to match. the trouble is that this must cater for users being able to log on to multiple computers so somewhere the computer names must match too when eliminating records.

i currently have the following query for selecting the most recent logon, but can't think how to eliminate the ones which have a matching logoff

with cte as (
	select *, ROW_NUMBER() over (partition by UserID orderby a.LoginDateTime desc) as seq from LoginAuditTable a where a.[State] = 1
select * from cte where seq = 1;

thanks for any help or pointers on how i might do this.


also, bear in mind that, although i have a reasonable knowledge of sql code, i'm not a very advanced developer, so......


I'm trying to share a Contact with another user. In this scenario, I would expect that only the contact would be shared and not the related entities like Opportunity/Activity etc. But what I see is whenever I'm sharing a Contact with other user it does share all Opportunities/Activities associated with that Contact. Other user is able to see related entity records even if those recrds are not explicitly shared. Can somebody please provide any solution to control this? What I want is, when I share a Contact it should not share related Opportunities/Activities/any of the related entity records.

Thank you



How to Programatically create records for Particular custom entity record in CRM.

For Example I have patient case custom entity, I want to create Audit entity records for

particular patient case (guid).

Any help appriciate...







Hi everyone, I want to share an account record and all the related records (5 new entities and there related entities too), i've already change the setup or the relationship setting the cascade rule up, and published all entities involved, but i just can not get what i want, any suggestion would help!!



Hi Guys,

I am trying to create an Account record from specific fields from another entity's (Mentorship) record.

I.E : when i save the mentorship's record, the plugin should kick in and take specific fields from the mentorhip entity's record and create a new Account record with those fields.

Any ideas on how to go about this guys?




Thank You.

i got some valuble information . and  needed one more  below clarification

how many default pages MSCRM  is having?

is it possible use my custom aspx page( having some style sheets) implemented to show the related entity records  of related entity on the one entity tab.


Hello.  Is it possible to have the insert link displayed even when there are no matching records?  I think I can use Newform.aspx for the first record instead, but would like to keep everything uniform if it's possible.  Thanks

with the sql statement below, i try to select the records based on the selected date, it return no rows from adapter filled datatable. 
however, when i run the query in sql query in sql server studio management, it returns records. 
date format = 09/28/2010

string[] splitDT = txtSelectedDate.Text.Split('/');

            string strRearrangeDT = splitDT[0] + "/" + splitDT[1] + "/" + splitDT[2];

using (SqlConnection sqlconn = new SqlConnection(connstring))
                DataTable dt = new DataTable();
                string strSQL = "SELECT userclaim_details3.id, userclaim_details3.userclaimid, userclaim_details3.userid, userclaim_details3.childcategorytableid, userclaim_details3.statusid, " +
                         "userclaim_details3.amount AS amountname, userclaim_details3.remark AS remarkname, userclaim_details3.datecreated AS datecreatedname, " +
                         "userclaim_details3.datemodified, approvaltable.id AS Expr1, approvaltable.typename AS statusname, usertable2.id AS Expr2, usertable2.name AS uname, " +
                         "childcategorytable.id AS Expr3, childcategorytable.categoryname AS categorynamename, childcategorytable.categorydescription AS catedescname " +
                        "FROM userclaim_details3 INNER JOIN " +
                         "approvaltable ON userclaim_details3.statusid = approvaltable.id INNER JOIN " +
                         "usertable2 ON userclaim_details3.userid = usertable2.id INNER JOIN " +
                         "childcategorytable ON userclaim_details3.childcategorytableid = childcategorytable.id " +
                         "WHERE CONVERT(varchar,userclaim_details3.datecreated,101) = '" + strRearrangeDT + "'";



We have hundreds of Publication we replicate via transact replication.


One such set of publications (all of them for the DB I will discuss) were found to have more records on the publisher than on the subscriber.


It was not a matter of a DML operation removing the records on the subscribers.


Here is a hit list of what happened and what we did …


1.       Found a replicated DB’s tlog had grown to a point where it no longer could grow due to a lack of  physical disc space.

2.       Tried to shrink the log file but was unable to.

3.       Executed command “SELECT name, log_reuse_wait_desc FROM sys.databases” and found “wait” was due to replication.

4.       Tried executing a CHECKPOINT, then a TLog backup and then another CHECKPOINT for good measure but still no luck on shrinking the tlog file.

5.       Checked repmon and it showed all publications were synced and there were no outstanding transactions to move.

6.       Entered a tracer token and it came back round trip in 6 seconds (all the way to Sydney Aus and back).

7.       All repl jobs were working (logreader) and none of the jobs were hung or running abnormally long.

8.       Looked in the SQL event logs and found this message displayed for the last few days:


Replication-Replication Transaction-Log Reader Subsystem: agent ASTDC-SQL05P-DfaSys2_Archive-3 scheduled for retry. The process could not execute 'sp_repldone/sp_replcounters' on 'ASTDC-SQL05P'.


9.       We decided to restart the SQL services for the Distributor server.

10.   Once it came back we check repl and all looked fine (just as it had before the reboot).

11.   We ran the log reuse SP again and the reuse no longer show “replication” on the DB.

12.   We were able to shrink it back 30GB.

13.   We executed sp_publication_validation and found that all three Pubs had issues with their associated subscribers concerning record counts.


Since we were in a pinch for time we dropped the subscribers from the publications, added the subs back and then re-synced them.


QUESTION IS … has anyone ran across an issue like this.


I would “figure” that if the records made it to the Publisher DB, then they should have made it to the TLog THUS replication “should” have been able to read the transactions from the log and replicate them out to the subscribers.


Thanks for any and all help!



I have a requirement where i need to map Leads to existing custom entity recods based on the matching.

I have a custom entity defined and have almost 2000 records for this. And i also have a N:N relation ship with Lead and the custom entity. Now, when ever a Lead is created I shouold be able to pick few fields from Lead and compare against few fields against the custom entity. Which ever records match in the custom entitiy i need to create a relationship for them with the Lead. The matching should be smart enough that the spelling mistakes in names should be handled. For example a Lead with full name as John Smith should match with the custom entity with name as Jonh Smith (John is incorrectly entered as Jonh in custom entity). This process can happen asynchronously when ever a lead is created or by a workflow at regular intervals of time. Can any one suggest me if we have any readily available tools for this?

Many Thanks




I have a table of users with some standard info (user_id, user_forename, user_surname), table of subjects (subj_id, subj_name) and a table of user subjects (user_id, subj_id, score)

I want to select a list of user_id where multiple subject matches are found - for example -

user_id | subj_id | score
1 | 1 | Excellent
1 | 2 | Excellent
1 | 3 | Good
2 | 1 | Excellent
2 | 2 | Poor

I want to produce a query where, I can find all users where subject 1 scores excellent AND subject 2 scores excellent, thus the result from the above example would simply be user 1. How do I go about that???

Thanks in advance


I have set up a make shift table to test a query



table #tmprefunds2(




,merchant varchar(30)


,transactionamount moneynotnull


,transactiontype varchar (1)notnull)




into #tmprefunds2(accountid,merchant,transactionamount,transactiontype)Values ('1234','p&o',200,'d')



into #tmprefunds2(accountid,merchant,transactionamount,transactiontype)Values ('1234','p&o',150,'C')



into #tmprefunds2(accountid,merchant,transactionamount,transactiontype)Values ('1234','ryanair',200,'C')



into #tmprefunds2(accountid,merchant,transactionamount,transactiontype)Values ('23564','ryanair',200,'d')



into #tmprefunds2(accountid,merchant,transactionamount,transactiontype)Values ('78925','easyjet',200,'C')

Transactiontype refers to whether the transaction is a credit or debit and what I would like to do is bring back the records where there is no corresponding merchant. So for this I would want to retrieve accountid 1234 and merchant Ryanair, and 78925 and easyjet. I would not want to bring back 1234 and P&o even though the amounts are different it is still to the same merchant.

Any Ideas?



Given this text:

acapo[code] testacapotestacapotestacapotest[/code]acapo[code] test2acapo2 testtest[/code]acapo

I want to find all substrings "acapo" which are inside matching tags [code]..[/code]. So it matches n.2,3,4,6 but doesn't match n.1, 5 and 7.

My current pattern (with free spacing):


This pattern seems to be OK, but it matches also the central substring "acapo" (n.5) between [/code] and [code]. I don't want that.

How can I solve this problem?


(?<SymbBlnkName>\r\n[a-z0-9 _().]+\t(([a-z0-9 ().%]+)|\t))

(\t{5,11}([a-z &]*)\t*\r\n\t\t)(?<Qty>[0-9])

the above both independantly matches the data listed below but when joines, no match

ADBE\t\tADOBE SYSTEMS INC\t\t\t\t\t\t\t\t
CSCO\t\tCISCO SYSTEMS INC\t\t\t\t\t\t\t\t
ECA\t\tENCANA CORP\t\t\t\t\t\t\tResearch\t
RY\t\tROYAL BANK OF CANADA\t\t\t\t\t\t\t\tMarket Research & Analysis
BANK OF MONTREAL AAT 30D CASHABLE GIC - ANNUAL DUE 12/10/2009 INT 2.400 %\t\t\t\t\t\t\t\t\t\tAbout your holdings FAQ

 I am showing the tab char as \t for ease of counting



 I also tried  (?<SymbBlnkName>\r\n[a-z0-9 _().]+\t(([a-z0-9 ().%]+)|\t))(\t{7,8}([a-z &]*)(\t{0,1}))\r\n\t\t(?<Qty>[0-9])

with no luck


Looking in the projects for The file was not found in a project Determining whether the checksum matches for the following locations

Locating source for 'mypath\myfile.vb'. Checksum: MD5 {51 e2 e 25 86 c0 1c f8 e1 5e 3a 17 4 1a ef c8}
Determining whether the checksum matches for the following locations:
1: mypath\myfile.vb Checksum: MD5 {b7 36 33 b1 12 bb 1b 5f 2b a1 6f ad a3 f3 e2 7} Checksum doesn't match.
The file 'mypath\myfile.vb' exists.
Looking in script documents for 'mypath\myfile.vb'...
Determining whether the checksum matches for the following locations:
1: mypath\myfile.vb Checksum: MD5 {b7 36 33 b1 12 bb 1b 5f 2b a1 6f ad a3 f3 e2 7} Checksum doesn't match.
Looking in the projects for 'mypath\myfile.vb'.
The file was not found in a project.
Looking in directory 'C:\Program  Files\Microsoft Visual Studio 9.0\VC\crt\src\'...
Looking in directory 'C:\Program  Files\Microsoft Visual Studio 9.0\VC\atlmfc\src\mfc\'...
Looking in directory 'C:\Program  Files\Microsoft Visual Studio 9.0\VC\atlmfc\src\atl\'...
Looking in directory 'C:\Program  Files\Microsoft Visual Studio 9.0\VC\atlmfc\include\'...
Looking in directory 'C:\'...
Looking in directory 'D:\'...
The debug source files settings for the active solution indicate that the debugger will not ask the user to find the file: mypath\myfile.vb.
The debugger could not locate the source file 'mypath\myfile.vb'.

I found the following thread:


but don't like any of the solutions offered there.

What I've done:

1 - Clean solution

2 -Stop IIS

3-Manually delete the contents of C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files

I still get the error.

Anyone else fixed it?




I need to count the no of all Opportunity enity records which are having Status="Actual PUM".

needs to be do it in Onchange event Javascript.

Please provide me some sample Javascript code for this.







I've a custom entity.

I would like to prevent the record to be deactive : i've below conditions
   -> IF Condition True -> Deactive
   -> Else do not deactive.

I set the primary entity = custom entity
message - > SetStateDynamicEntity
stage = Pre / Synchronous / Server

Even when condition if false, the record is still getting deactive after showing the error message.

Please let me know where im going wrong.


I have a workflow that creates a new Task when a record of a custom entity ("Offers") is deactivated.  This workflow inserts the new Task in the Account's history showing that the Offer record was deactivated, including details from the Offer record built dynamically within the task.

My problem is, the "Created By" of the Task created by the workflow always shows as me, as the owner of the workflow.   To make sure our reporting/dashboards show the true number of tasks created by a user, I need for the Task to show created by the user that deactivated the Offer record (which was the triggering event for the workflow).

I'm not able to find a way in researching this to cause the "Created By" of the new Task record to be anyone other than the owner of the workflow.  Is this possible??  Thanks!!



I am using optimistic concurrency in my entity framework model setting the concurrency mode of my timestamp columns to Fixed. When I do that, every time I insert a new record that has a relationship to another table, it updates the parent before the insertion to validates that the parent still has the same timestamp, then get a new timestamp after the update and complete the insertion. Here is what the query looks like:

declare @p int
update [dbo].[ParentEntity]
set @p = 0
where (([ParentEntityId] = @0) and ([Timestamp] = @1))
select [Timestamp]
from [dbo].[ParentEntity]
where @@ROWCOUNT > 0 and [ParentEntityId] = @0
-- @0 (dbtype=Int32, size=0, direction=Input) = 1
-- @1 (dbtype=Binary, size=8, direction=Input) = System.Byte[]

This is a problem in our scenario, because we do not want the parent entity to get a new timestamp every time an entity that relates to it gets updates, but we still want the concurrency check to occur when we modify this entity directly. Here is an example of my scenario. We have an application with two tables : State and City. City has a relation to State. We have two different window to edit the cities and the states. A user open a window to edit a state on his computer, and another user creates a new city that has this state as his parent. I do not want to block the insertion of the city if the state is modified first, and I do not want the modification of the state to fail if a new city was added. That was working fine with LINQ to SQL. The concurrency was only checking the entity being modified or inserted, not all the parents that have concurrency mode set to fixed too.

Once way to fix this would be to add stored procs for every table we have in our database to insert and update the entities, but I don't want to create more than 500 procedures only to solve this issue. Anyone here has a solution to this?




I the following code to associate two entities:


_dataContext.AddLink(CurrentVolunteer, "Groups", value);


This creates the link and also updates the entities in the context and is working as expected.

If I try and do the reverse and remove the association I end up with a request to delete the entity all together!


_dataContext.DeleteLink(CurrentVolunteer, "Groups", group);

Results in:

DELETE http://localhost.:51750/DataService.svc/Volunteers(5)/$links/Groups(4) HTTP/1.1

DELETE http://localhost.:51750/DataService.svc/Groups(4) HTTP/1.1

Is this a bug or am I going about it the wrong way??




<< Previous      Next >>

Microsoft   |   Windows   |   Visual Studio   |   Sharepoint   |   Azure