Showing posts with label ms crm. Show all posts
Showing posts with label ms crm. Show all posts

Thursday, January 20, 2011

saving another entity form from one form

Suppose we want to put an entity record in another entity form and on change of anything in the parent we also want to put the value in the child record and also want to save that. This can be done :)

var iframe = crmForm.all.IFRAME_CustomEntity
var iDoc = iframe.contentWindow.document;
var iframe_isSaved = true;

// checking if the Custom Entity has been changed
if (iDoc.crmForm.IsDirty())
{
// save Custom Entity
var iframe_isSaved = iDoc.crmForm.Save();
}

if (iframe_isSaved == false) // validation failed on Custom entity
{
event.returnValue = false; // Cancel the SAVE on Account
return false;
}

Just test and see.

Wednesday, October 27, 2010

Disabling Notes for deactivated records MS CRM

In the OnLoad event:




Code Snippet
/* [s] Disables the creation of new Notes, and editing of existing notes. Attachments can still be opened. */
//If the 'Close' button is showing, means that form Status = Resolved or Cancelled
var btnClose = document.getElementById("_MBwindowclose");
if (btnClose != null)
{
//Need to attachEvent, because IFRAME elements load asynchronously, and elements like 'newNoteButton' are not accessible on form load
var iframe = document.getElementById("notescontrol");
iframe.attachEvent('onreadystatechange', DisableNotes);
}
/* [e] */





The function DisableNotes:




Code Snippet
function DisableNotes()
{
//Hide 'Create a New Note' link
window.frames[0].document.getElementById('newNoteButton').style.visibility="Hidden";
var NotesTable = window.frames[0].document.getElementById('NotesTable');
//Disable the entire table
NotesTable.disabled = true;
var TextArea = NotesTable.getElementsByTagName('TEXTAREA');
//It's still necessary to individually disable the Textareas where users edit the existing notes.
for (i=0;i<TextArea.length;i++)
{
TextArea[i].disabled = true;
}

return;
}

Tuesday, October 12, 2010

Change typename in lookup ms crm

i have one challenge as follows, if you can....

on look up, onclick of it a popup window will come, there you can select a record.

there also a picklist will be there(sometimes) where you can also change. the best example is the regarding attribute on letter.

suppose on that picklist i have 3 options as a,b,c.

bydefault a is selected and on basis of some condition i want b to be selected.
its doable and as follows.

just put the following code on load of the form.

crmForm.all..defaulttype = "2";//the number of the picklist value, starts from 1


Sudhanshu

Tuesday, December 1, 2009

MARK BUSINESS REQUIRED MANUALLY

Sometimes we need to make the attributes(fields) "Business Required" manually , when the crmForm.SetFieldReqLevel("fieldname", 1); stops working ie any changes has been done in the attribute level.

//for business required which will put a red asterisk side to the attribute
//it only takes one parameter as new_attributeName_c
function markRequired(lbl)
{
if(lbl !=null){
if(lbl.childNodes[0] != null && lbl.childNodes[0].innerText != undefined){
html = lbl.childNodes[0].innerHTML +"<IMG alt='Required' src='/_imgs/frm_required.gif'/>";
}else{
html = lbl.innerHTML +"<IMG alt='Required' src='/_imgs/frm_required.gif'/>";
}
lbl.innerHTML = html;
}
}

//for not business required which will remove the red asterisk side to the attribute
//it only takes one parameter as [i]new_attributeName_c
function markOptional(lbl) {
if(lbl !=null){
if(lbl.childNodes[0] != null && lbl.childNodes[0].innerText != undefined){
html = lbl.childNodes[0].innerText ;
}else{
html = lbl.innerText ;
}
lbl.innerHTML = html;
}


//on save also we need to check it manully and return back to the same form without saving the details and
//the focus need to be on the required attribute(field) provided the field should not be read-only
if(crmForm.all.new_attributeName.DataValue == null){
crmForm.all.tabName.click();
crmForm.all.new_attributeName.focus();
alert("Attribute is Required.");
event.returnValue = false;
return false;
}

//[i]Just some Re-engineering will give a lot