Convert TextBox field to Button with javascript

Hi, we can add a button to a solution crm with The Ribbon Workbench ribbonworkbench , Or we can convert a textBox Filed to button ,
So I create a filed type text and i added a code with javascript to change this field to button.
txtbox convert to button Dynamics crm 2013
this is the code of the custum button :

function ajoutButton(new_convertir) {
if (document.getElementById(new_convertir) != null) {
var sFieldID = "field" + new_convertir;
var elementID = document.getElementById(new_convertir + "_d");
var div = document.createElement("div");
div.style.width = "50%";
div.style.textAlign = "right";
div.style.display = "inline";
elementID.appendChild(div, elementID);
div.innerHTML = ' Convertir';

documew_cnt.getElementById(neonvertir).style.width = "0%";
document.getElementById(sFieldID).ondblclick = function () { DateDifference(); };
}
}

I get this result :
gestionrectif.png-550x0

Advertisements

fetchxml linked-entity with lookup filter

Hello, In this article i will share with you how to add a lookup filter to a linked entity with Fetchxml

In the serviceappointment entity ,  i added  a lookup  field “new_contract”  to diplay the list of contract,
 so i want to display the list of contract of the selected account.

i create a fetchxml filter and i added it to javascript function :

function preFilterLookup() {
Xrm.Page.getControl("new_contrat").addPreSearch(function () {
addLookupFilter();


});
}
function getlookupCustomer()
{
var lookupObject = Xrm.Page.getAttribute("customers");

if (lookupObject != null) {

var lookUpObjectValue = lookupObject.getValue();

if ((lookUpObjectValue != null)) {

var lookuptextvalue = lookUpObjectValue[0].id;
return lookuptextvalue;

}
}
}
function addLookupFilter() {
var customer = getlookupCustomer();

if (customer != null) {

fetchXml = ""
+ " "
+ "";
Xrm.Page.getControl("new_contrat").addCustomFilter(fetchXml);
}
}