1. In Case Entity, based on Incident Type selection, filter the case category using the category-incident master entity
User story: In Case Entity, based on Incident Type selection, filter
the case category using the category-incident master entity
2. Create the entity with the name of Case category
3. Create Master entity with the name of category incident type
·
Create one Incident type field with lookup
datatype for Incident type entity lookup
·
Create one Category type field with the look
data type for case category entity lookup
·
Write JavaScript function for name of the
category incident type record with the combination of incident type and
category type
·
Write JavaScript function: On form load if
Incident type is null then category type in disable (read only) mode otherwise
it is enabling mode
·
Write JavaScript function: On Incident type
field change if Incident type field not qual to null then enable category type
otherwise disable mode.
5.
prepare fetchxml from the advanced find view to
get the case categories based on incident type6.
create custom filter view to show retrieved case
categories
1.Create 3entities with the
name of Incident Type, Case category,
category incident type
2. In master Entity Provide
look up for Incident Type and Case
Category
3.Write JavaScript function for
name of the category incident type record with the combination of incident type
and category type and call it from category field on change.
//
categorytype field onchange
function category_incidentType(executionContext) {
var
formContext = executionContext.getFormContext();
var
incidentType = formContext.getAttribute("effi_incidenttype").getValue();
var
caseCategory = formContext.getAttribute("effi_categorytype").getValue();
if
(incidentType != null && caseCategory !== null) {
var
incident_name = incidentType[0].name;
var
caseCategory_name = caseCategory[0].name;
var
fullname = incident_name + " " +
caseCategory_name;
formContext.getAttribute("effi_name").setValue(fullname);
}
}
4.Write JavaScript function: On
form load if Incident type is null then category type in disable (read only)
mode otherwise it is enabling mode and call it from form onload
// Form OnLoad
function cat_Type(executionContext)
{
var
formContext = executionContext.getFormContext();
var
incident = formContext.getAttribute("effi_incidenttype").getValue();
if
(incident == null || incident == undefined)
{
formContext.getControl("effi_categorytype").setDisabled(true);
}
else
{
formContext.getControl("effi_categorytype").setDisabled(false);
}
}
// incidenttype field on change
function inc_type(executionContext) {
var
formContext = executionContext.getFormContext();
var inc = formContext.getAttribute("effi_incidenttype").getValue();
if (inc !=
null) {
formContext.getControl("effi_categorytype").setDisabled(false);
}
else
{
formContext.getControl("effi_categorytype").setDisabled(true);
}
}
6.In case entity Provide the
lookup for Incident Type and Case Category
7. prepare fetchxml from
the advanced find view to get the case categories based on incident type
7. Write JavaScript function to create custom filter view to show retrieved case categories and call it from incident type field on change
function filterCaseCategory(executionContext) {
var
formContext = executionContext.getFormContext();
var incT =
formContext.getAttribute("new_incidenttype").getValue();
var caseT =
formContext.getAttribute("new_casecategory").getValue();
if (incT
!= null && incT != undefined) {
var incT_id
= incT[0].id;
var
incT_name = incT[0].name;
var viewId
= "00000000-0000-0000-0000-000000000008";
var
viewName ="effi_efficasecategory"
var
viewDisplayName = "FilteredCaseCategory";
//var filterFn = function (executionContext) {
// var
formContext = executionContext.getFormContext();
var
filterXml = "<fetch
version='1.0' output-format='xml-platform' mapping='logical'
distinct='true'>" +
"
<entity name='effi_efficasecategory'>" +
"
<attribute name='effi_efficasecategoryid' />" +
"
<attribute name='effi_name' />" +
"
<attribute name='createdon' />" +
"
<order attribute='effi_name' descending='false' />" +
"
<link-entity name='effi_categoryincidenttype'
from='effi_categorytype' to='effi_efficasecategoryid' link-type='inner'
alias='ab'>" +
"
<filter type='and'>" +
" <condition
attribute='effi_incidenttype' operator='eq' uiname='" + incT_name + "' uitype='effi_effiincidenttype'
value='" +
incT_id + "'
/>" +
"
</filter>" +
"
</link-entity>" +
"
</entity>" +
"</fetch>";
var layout
=
"<grid name='resultset' icon='1'
preview='1' select='1' jump='effi_name' object='5'>" +
"<row name='result'
id='effi_efficasecategoryid' >" +
"<cell name='effi_name'
width='300'/>" +
"<cell name='createdon'
width='300'/>" +
"</row>" +
"</grid>";
formContext.getControl('new_casecategory')
.addCustomView(viewId,
viewName,viewDisplayName,filterXml,layout,true);
//}
//formContext.getControl('new_incidenttype').addPreSearch(filterFn);
}
else
{
return false;
}
}
Write JavaScript function to create custom filter view to show retrieved Incident types and call it from case category field on change
function filterIncidentType(executionContext) {
var
formContext = executionContext.getFormContext();
var
incTypeLookup = formContext.getAttribute("new_incidenttype").getValue();
var
caseTypeLookup = formContext.getAttribute("new_casecategory").getValue();
if
(caseTypeLookup != null && caseTypeLookup != undefined) {
var Cid =
caseTypeLookup[0].id;
var cName =
caseTypeLookup[0].name;
var viewId
= "00000000-0000-0000-0000-000000000008";
var
viewName = "effi_effiincidenttype"
var
viewDisplayName = "CaseType";
//var filterFn = function (executionContext) {
// var
formContext = executionContext.getFormContext();
var
filterXml = "<fetch
version='1.0' output-format='xml-platform' mapping='logical'
distinct='true'>" +
" <entity
name='effi_effiincidenttype'>" +
"
<attribute name='effi_effiincidenttypeid' />" +
"
<attribute name='effi_name' />" +
"
<attribute name='createdon' />" +
" <order
attribute='effi_name' descending='false' />" +
"
<link-entity name='effi_categoryincidenttype'
from='effi_incidenttype' to='effi_effiincidenttypeid' link-type='inner'
alias='ac'>" +
"
<filter type='and'>" +
"
<condition attribute='effi_categorytype' operator='eq' uiname='" + cName +"' uitype='effi_efficasecategory' value='" + Cid +"' />" +
"
</filter>" +
"
</link-entity>" +
"
</entity>" +
"</fetch>"
var layout
=
"<grid name='resultset' icon='1' preview='1'
select='1' jump='effi_name' object='5'>" +
"<row name='result' id='effi_effiincidenttypeid'
>" +
"<cell name='effi_name' width='300'/>" +
"<cell name='createdon' width='300'/>" +
"</row>" +
"</grid>";
formContext.getControl('new_incidenttype')
.addCustomView(viewId, viewName,
viewDisplayName, filterXml, layout, true);
//}
//formContext.getControl('new_incidenttype').addPreSearch(filterFn);
}
else {
return false;
}
Comments
Post a Comment