Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Use Lookup in own Applications

37 views
Skip to first unread message

simonsturzenegger

unread,
May 8, 2006, 8:52:02 AM5/8/06
to
Hi all,

I'm trying to use the CRM Lookup in my own application. I want to get the ID
of the contact, I select in the lookup window.
Someone told me I should be able to receive the return value with the
following code:

var ret =
window.showModalDialog("http://<server>/_controls/lookup/lookupsingle.aspx?class=null&objecttypes=2,8&browse=0");

alert(ret.items[0].id);

But I always get the following Script error: "items is null or not an object"

Can someone tell me, how I can get the ID of the chosen contact? I don't
know how to get the right return value.

Thanks for your help!


Regards, Simon

Fabio Claudio Ferracchiati

unread,
May 8, 2006, 9:16:03 AM5/8/06
to
Hi,
this code snipett is from CRM SDK:

var lookupItem = new Array;

// This will get the lookup for the attribute primarycontactid on the
Account form.
lookupItem = crmForm.all.primarycontactid.DataValue;

// If there is data in the field, show it in a series of alerts.
if (lookupItem[0] != null)
{
// The text value of the lookup.
alert(lookupItem[0].name);

// The entity type name.
alert(lookupItem[0].typename);

// The GUID of the lookup.
alert(lookupItem[0].id);

// The entity type code of the lookup: 1=account, 2= contact.
alert(lookupItem[0].type);
}

HtH

simonsturzenegger

unread,
May 8, 2006, 9:28:02 AM5/8/06
to
Hi Fabio,

That's not what I mean. I want to use the lookup in my own site, my own
application. There I don't have access to the crmForm.


Regards, Simon

Fabio Claudio Ferracchiati

unread,
May 8, 2006, 10:07:02 AM5/8/06
to
Sorry for that... However, when you press the OK button in the Lookup form,
the ret value you used points to a windows that doesn't exist anymore. That's
normal you retrieve that error.

simonsturzenegger

unread,
May 8, 2006, 10:19:02 AM5/8/06
to
Well that's interesting! :-)

Is there a possibility to save the ret value from the Lookup form?

rakesh

unread,
May 9, 2006, 1:03:26 AM5/9/06
to
just now i went to groups and saw your post . i think u require this

<body MS_POSITIONING="GridLayout" onload="javascript:LoadLookUp();">
<form name=frm id=frm >
<table ID="Table1">
<tr>
<td>Duplicate Defect Reference</td>
<td>
<table class="lu"
cellpadding="0" cellspacing="0" width="100%"
style="table-layout:fixed;"
ID="Table2">
<tr>
<td><div
class="lu" id=lu1 ></div>
</td>
<td width="25"
style="text-align: right;"><img
src="/_imgs/btn_off_lookup.gif" id="productid"

onclick="showlookup()"></td>
</tr>

</table>

</form>
</body>

this will be in html page ( i have used iframe for this )


function LoadLookUp()
{

if(top.IFRAME_first.frm.getElementsByTagName("div")[0]!= null)
{

var
obj2=top.IFRAME_first.frm.getElementsByTagName("div")[0];
//setting the lookup in the html form
var obj1=parent.document.createElement("SPAN");
obj1.className= "lui";
obj1.oid="";
//set the object type
obj1.otype="";
obj1.innerHTML="";
obj2.innerHTML=obj1.outerHTML;

}
}


no in the loadlookup you call ur own code
this will help you

simonsturzenegger

unread,
May 9, 2006, 2:44:01 AM5/9/06
to
Don't really get this to work...Do you have an example, you can send to me?

Did you import any of the lookup js files?

Regards, Simon

rakesh

unread,
May 9, 2006, 2:50:21 AM5/9/06
to
<link rel="stylesheet" type="text/css"
href="/_common/styles/global.css">
<link rel="stylesheet" type="text/css"
href="/_common/styles/fonts.aspx">
<link rel="stylesheet" type="text/css"
href="/_forms/controls/controls.css">
<link rel="stylesheet" type="text/css"
href="/_common/styles/select.css">
<link rel="stylesheet" type="text/css"
href="/_forms/controls/form.css">

i have imported this css file

showlookup() method write the function

var ret =
window.showModalDialog("http://<server>/_controls/lookup/lookupsingle.aspx?­class=null&objecttypes=2,8&browse=0");

rakesh

unread,
May 9, 2006, 3:15:02 AM5/9/06
to
hi i am pasting the htm file for you

just place this file in the crmwebfolder

say you named this file as rakesh.html

http:\\<crmserver>\rakesh.html


if you place it any where else then you have to change the url for
lookup and the refrences

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>

<title>contact</title>

<link rel="stylesheet" type="text/css"
href="/_common/styles/global.css">

<link rel="stylesheet" type="text/css"
href="/_common/styles/fonts.aspx">
<link rel="stylesheet" type="text/css"
href="/_forms/controls/controls.css">
<link rel="stylesheet" type="text/css"
href="/_common/styles/select.css">
<link rel="stylesheet" type="text/css"
href="/_forms/controls/form.css">

<script language=javascript>

function showlookup()

{
var url;


url = "/_controls/lookup/lookupsingle.aspx";
url += "?class=null"
url += "&objecttypes=2"
url += "&browse=0"

var lookupItems = window.showModalDialog(url,"488px,498px");

alert(lookupItems.items[0].id);
}

function LoadLookUpFromDefectInfo()
{


var obj2=frm.getElementsByTagName("div")[0];

//setting the lookup in the html form
var obj1=parent.document.createElement("SPAN");
obj1.className= "lui";
obj1.oid="";
//set the object type
obj1.otype="";
obj1.innerHTML="";
obj2.innerHTML=obj1.outerHTML;


}


//------------------------------
function LoadLookUp()
{


LoadLookUpFromDefectInfo()

}
//------------------

</script>

</head>


<body MS_POSITIONING="GridLayout"
onload="javascript:LoadLookUp();">
<form name=frm id=frm >
<table ID="Table1">
<tr>
<td>Duplicate Defect Reference</td>
<td>
<table class="lu"
cellpadding="0" cellspacing="0" width="100%"
style="table-layout:fixed;"
ID="Table2">
<tr>
<td><div
class="lu" id=lu1 ></div>
</td>
<td width="25"
style="text-align: right;"><img
src="/_imgs/btn_off_lookup.gif" id="productid"

onclick="showlookup()"></td>
</tr>

</table>

</form>
</body>

</html>

simonsturzenegger

unread,
May 9, 2006, 3:28:02 AM5/9/06
to
Perfect!!!!!!

Thanks very much! It's working now. I always tried to open the html file
directly in the crm folder instead of browsing to the file with the internet
explorer.

Thanks again!

May you know, how I can deactivate the "New" button in the lookup?

Regards, Simon

0 new messages