function Calculations()// to get marks of all student courses marks related to student
{
var stdId = Xrm.Page.data.entity.getId();
if (stdId != null)
{
var EntityNameP, ArrayNamesP, ArrayValuesP;
ArrayValuesP = stdId;
var _query = "?$filter=cms_Student/Id eq (Guid'"+stdId+"')";
var obj = RecRetrieveMultiple(_query, "cms_studentcourse");
var entityNodesP = obj;
var TotalPoints = 0;
for (var i = 0; i < entityNodesP.length; i++)
{
var entityNode = entityNodesP[i];
var Node = entityNode.cms_ObtainedMarks;//get simple field
var level = entityNode.cms_level.Value;
var courselevel = entityNode.cms_CourseId.Name;//get lookup value from child entity
var courselevel1 = entityNode.cms_CourseId.Id;//get lookup id from child entity
var ResultNode = (Node == null) ? 0 : parseFloat(Node);
TotalPoints = parseFloat(TotalPoints) + parseFloat(ResultNode);//sum of all student courses marks
}
}
}
function RecRetrieveMultiple(_query, _entityname){
var contacts;
XrmSvcToolkit.retrieveMultiple({
entityName: _entityname,
async: false,
odataQuery: _query,
successCallback: function (result) {
contacts = result;
},
errorCallback: function (error) {
alert("Error");
}
});
var _result = contacts;
return _result;
}
{
var stdId = Xrm.Page.data.entity.getId();
if (stdId != null)
{
var EntityNameP, ArrayNamesP, ArrayValuesP;
ArrayValuesP = stdId;
var _query = "?$filter=cms_Student/Id eq (Guid'"+stdId+"')";
var obj = RecRetrieveMultiple(_query, "cms_studentcourse");
var entityNodesP = obj;
var TotalPoints = 0;
for (var i = 0; i < entityNodesP.length; i++)
{
var entityNode = entityNodesP[i];
var Node = entityNode.cms_ObtainedMarks;//get simple field
var level = entityNode.cms_level.Value;
var courselevel = entityNode.cms_CourseId.Name;//get lookup value from child entity
var courselevel1 = entityNode.cms_CourseId.Id;//get lookup id from child entity
var ResultNode = (Node == null) ? 0 : parseFloat(Node);
TotalPoints = parseFloat(TotalPoints) + parseFloat(ResultNode);//sum of all student courses marks
}
}
}
function RecRetrieveMultiple(_query, _entityname){
var contacts;
XrmSvcToolkit.retrieveMultiple({
entityName: _entityname,
async: false,
odataQuery: _query,
successCallback: function (result) {
contacts = result;
},
errorCallback: function (error) {
alert("Error");
}
});
var _result = contacts;
return _result;
}
No comments:
Post a Comment