Hide and Show Section Using Java Script in CRM

In this article , I am going to explain how to hide sections

Hiding Section

-Xrm.Page.ui.tabs.get(tabIndex).sections.get(sectionIndex).setVisible(false);
-Xrm.Page.ui.tabs.get(tabIndex).sections.get("sectionName").setVisible(false);

Showing Section

-Xrm.Page.ui.tabs.get(tabIndex).sections.get(sectionIndex).setVisible(true);
-Xrm.Page.ui.tabs.get(tabIndex).sections.get("sectionName").setVisible(true);

Add Note To Existing Case Using C# SDK in CRM

Suppose you have customized the "Case" Entity to match the business of a call center in which client reports complaints which are save as cases, and you would like to add a comment to this case.

CRM implements this by default in the "Note" Entity which has a relationship with the "Case" Entity

How to Create a Note and relate it to specific case ?!

Code:

 Using Early Bound

//"Annotation" is the schema name while "Note" is the display name
Annotation NewAnnotation = new Annotation();

//The comment you want to write to this specific case
NewAnnotation.NoteText = "your comment";

//"incident" is the logical name of the "Case" Entity and IncidentID is the GUID of the record.
NewAnnotation.ObjectId = new Microsoft.Xrm.Client.CrmEntityReference("incident", IncidentID);

//Set the title of the "Note"
NewAnnotation.Subject +="The title of the Note";

// Add the Note
context.AddObject(NewAnnotation);

// Save the changes
context.SaveChanges();

Using Late Bound

Entity Note= new Entity("Annotation");

//The comment you want to write to this specific case
Note["notetext] = "your comment";

//The "ObjetID" is the ID if the record you want to assign the note to it (Note can be assigned to many type of entities not just case)

//"incident" is the logical name of the "Case" Entity and IncidentID is the GUID of the record.
Note["ObjectId"] = new Microsoft.Xrm.Client.CrmEntityReference("incident", IncidentID);

//Set the title of the "Note"
Note["Subject"] = "Your Title";

//Create the record
OrganizatoinService.Create(Note);

Retrieve Fields Values Using Late Bound In CRM

The following code shows how to retrieve the value of many fields of different types in CRM , let's apply this behavior on a record of the "Account" Entity.

Code:

//Get the record of the "Account" entity.
Entity _Account = OrganizationService.Retrieve("account", new Guid("recordguid"), new ColumnSet(){AllColumns=true});

//To get string value
string Name = _Account["name"].ToString();

//To get Option Set selected value

int OptionSetValue = ((OptionSetValue)_Account["accountcategorycode"]).Value;

//To get  Option Set selected text

String  OptionSetTest = ((OptionSetValue)_Account.FormattedValue["accountcategorycode"]).Value;

//To get  date time field value

DateTime CollectionDate = ((DateTime)_Account["new_collectiondate"]).Date;

//To get  money field value

decimal Creditlimit = ((Money)_Account["creditlimit"]).Value;

//To fetch decimal field value

decimal Executivecommission = (decimal)_Account["new_executivecommission"];

Assign Case To Queue Using C# SDK

AddToQueueRequest addToQueue = new AddToQueueRequest
{

//queueId is the Guid of queue to which you want to assign the case
DestinationQueueId = queueId,

//"incidnet" is the logical name of entity and _incidentId is the Guid of the record
Target = new EntityReference("incident", _incidentId)

};

OrganizationService.Executte(addToSourceQueue);