I have this C# class below which returns Communication on a particular date which I am able to print on an HTML table. Now I need to take that output in JSON format and pass-on to vis Timeline. I have no idea how I can do it. If I can use "For JSON" in SQL query it can return query output in JSON but still I want to put everything together in C# code from where I can create a dll with everything in it.
using System;
using System.Drawing;
using System.Collections.Generic;
using System.Text;
using Sage.CRM.Blocks;
using Sage.CRM.Controls;
using Sage.CRM.Data;
using Sage.CRM.HTML;
using Sage.CRM.Utils;
using Sage.CRM.WebObject;
using Sage.CRM.Graphics;
using Sage.CRM.UI;
using System.Data;
namespace QuickLook
{
class QuickLook : Web
{
public override void BuildContents()
{
GetTabs();
AddContent(HTML.Form());
//Communications
string strHtml = "
";
string varleadid= GetContextInfo("Lead", "Lead_leadid");
string querySQL = "select comm_createddate, Comm_Subject from vcommunication where comm_deleted is null and comm_leadid= " + varleadid;
I'd recommend to learn asp.net first and then about integrating with Sage CRM. I got the feeling that you're on the wrong way. Also this component is not really trivial to integrate. That said, here is a bit of code from a project where I have it integrated:
The action on the controller:
[HttpGet]
[AjaxOnly]
public JsonResult Data(int id, int pos, DateTime startDate, DateTime endDate)
{
//Read data from db:
var result = _db.Schemas.ReadMyData(siteId, pos, startDate, endDate).ToList();
//Create groups out of the results
List<object> mainGroups = new List<object>
{
new
{
id = no + 1,
order = 1L,
content = "MainGroup",
//nestedGroups = set nested groups as needed
}
};
//Return the whole thing as json
return Json(new
{
mainGroups,
result
}, JsonRequestBehavior.AllowGet);
}
Then if your results map to the groups and items of vis you can do:
// DOM element where the Timeline will be attached
let container = document.getElementById("visElement");
$(container).empty(); // Empty out the html. Renders the overview faster than updating existing data
// create a data set with groups
let groups = new DataSet();
// Create a DataSet (allows two way data-binding)
let items = new DataSet();
groups.add(data.mainGroups);
items.add(data.result);
// create a Timeline
var timeLine = new Timeline(container, items, groups, options);
Thanks for this, even I was not sure for my approach that's the reason I raised it here. I can see you are using Ajax. Before thinking for this approach I wish to know, is it possible to call vis libraries in C# ?
The way I work in Sage CRM. I have created a .net dll (from the code I shared on top) which is capable of fetching data in JSON, now I was thinking if I can call vis libraries in .Net and display the vis Timeline from their, it will make my life simple.
Hiya,
I have this C# class below which returns Communication on a particular date which I am able to print on an HTML table. Now I need to take that output in JSON format and pass-on to vis Timeline. I have no idea how I can do it. If I can use "For JSON" in SQL query it can return query output in JSON but still I want to put everything together in C# code from where I can create a dll with everything in it.
using System; using System.Drawing; using System.Collections.Generic; using System.Text; using Sage.CRM.Blocks; using Sage.CRM.Controls; using Sage.CRM.Data; using Sage.CRM.HTML; using Sage.CRM.Utils; using Sage.CRM.WebObject; using Sage.CRM.Graphics; using Sage.CRM.UI; using System.Data;
namespace QuickLook { class QuickLook : Web { public override void BuildContents() {
//Communications string strHtml = "
}
Thanks in Advance Sharad
I'd recommend to learn asp.net first and then about integrating with Sage CRM. I got the feeling that you're on the wrong way. Also this component is not really trivial to integrate. That said, here is a bit of code from a project where I have it integrated:
The action on the controller:
Then if your results map to the groups and items of vis you can do:
Hi Jogai,
Thanks for this, even I was not sure for my approach that's the reason I raised it here. I can see you are using Ajax. Before thinking for this approach I wish to know, is it possible to call vis libraries in C# ?
The way I work in Sage CRM. I have created a .net dll (from the code I shared on top) which is capable of fetching data in JSON, now I was thinking if I can call vis libraries in .Net and display the vis Timeline from their, it will make my life simple.
Thanks in advance ! Sharad
No, its a clientside library.