Problem: -I need to c amount of related entity B tied to parent entity A. -1 Entity A : Many Entity B -Need auto numbering on amount of related record (entity B) tied to entity A. |
Solution: -Add function during onLoad(); -Add one ref javascript Name Navi_AutoNumber.js |
eg. onLoad Script function onLoad() { GetAssociatedRecords("Entity B Name", "Entity B Look Up Field Scheme Name", "Relation Name"); } |
eg. Navi_AutoNumber.js function GetAssociatedRecords(associatedEntityName, primaryIdSchemaName, relationshipSchemaName){ try{ if(Xrm.Page.data.entity.getId() != null){ var bProceed = false; var nav = 'nav_' + relationshipSchemaName; var items = Xrm.Page.ui.navigation.items.get(); for (var i in items) { var item = items[i]; if(item.getId().toLowerCase() == nav.toLowerCase()){ bProceed = true; break; } } if(bProceed){ var relationshipIdvalue = Xrm.Page.data.entity.getId(); var columns = []; var Filter = primaryIdSchemaName + "/Id eq (guid'" + relationshipIdvalue + "')" var Collection = CrmRestKit.RetrieveMultiple(associatedEntityName, columns, Filter); var totalRecords = Collection.results.length; if(document.getElementById(nav) != null) { document.getElementById(nav).getElementsByTagName('NOBR')[0].innerText = " (" + totalRecords + ")" + document.getElementById(nav).getElementsByTagName('NOBR')[0].innerText ; } //return Collection; } } }catch(err){ alert(err); } } |
How it will look Like |
CRM 2011 Related Entity Numbering/ Calculate Amount Of Related Entity Records
Posted by Unknown at 1/23/2013 03:55:00 pm
Labels: CRM 2011, Javascript
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment