Javascript-Befehl: partylist

Hallo Ihr,



habe Schwierigkeiten mit dem Javascript-Befehl "partylist".

Fange auch erst gerade an mit dieser Sprache zu programmieren.





Wir wollen bei uns im CRM eine Befehl einbinden, der im Feld "Von" vom
E-Mail Formular immer den selben "User" einträgt und ich möchte es mit
Javascript machen, d.h. eigentlich muss ich es mit Javascript machen,
weil meinem Probieren nach, es mit einem Workflow nicht zu machen ist.



Für das Vorhaben muss man ja auch diese GUID verwenden, die habe ich mittels eines Codes, von hier (etwas umgeändert natürlich), heraus bekommen können, aber wie verwende ich diese GUID in dieser blöden partylist?

Habt Ihr ein paar Tipps? Wäre für jeden Dankbar



Viele Grüße
Frank


Re: Javascript-Befehl: partylist

Das steht im CRM 3.0 SDK beschrieben.


Field Type: Lookup or PartyList
http://msdn2.microsoft.com/en-us/library/aa681853.aspx


A Lookup object is defined with the following attributes:




























Attribute Type Description
id String The GUID of the item. Required for set.
type Integer Deprecated. The object type code.
typename String The entity name of the item. Required for set.
name String The name of the item to be displayed. Required for set.
data   Any other data. Optional for set.


The following properties are available:












Lookup or PartyList properties Type Description
{Field}.DataValue An array of lookup objects Get/set property.

For single lookups this must be an array with the length of one. DataValue is Null when no value is selected. Set DataValue to Null to make the lookup field blank.


Example


The following code example shows how to read values from a field of type Lookup.


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 GUID of the lookup.
alert(lookupItem[0].id);

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

// The entity type code of the lookup: 1=account, 2= contact.
// This attribute is deprecated. Use typename instead.
alert(lookupItem[0].type);
}

Example


The following code example shows how to set values in a field of type Lookup. This example shows how to set the parent account lookup field on the account form.


//Create an array to set as the DataValue for the lookup control.

var lookupData = new Array();
//Create an Object add to the array.
var lookupItem= new Object();
//Set the id, typename, and name properties to the object.
lookupItem.id = '{1AAC1363-01A1-DB11-8432-0003FF9CE217}';
lookupItem.typename = 'account';
lookupItem.name = 'A Bike Store';
// Add the object to the array.
lookupData[0] = lookupItem;
// Set the value of the lookup field to the value of the array.
crmForm.all.parentaccountid.DataValue = lookupData;


AW: Re: Javascript-Befehl: partylist



Hallo Jürgen,


vielen Dank, für deinen Tipp. Es funktioniert jetzt endlich






Eigentlich hatte ich mir dieses Beispiel ja schon mal
angeschaut,

aber jetzt wo Du die Seite noch mal vorgeschlagen hattest, habe

ich noch mal intensiver probiert. Mein Bedenken bei dem Example,

war wohl der Teil mit dem „lookupData = new
Arra
()“, also das

neue Array, weil der Code vielleicht den bestehenden Datensatz

neu erstellt oder verändert oder sowas.
Ich wollte nämlich eher mit „get Array“ probieren, aber das geht,
glaub ick, gar nicht.


Gruß Frank



AW: Re: Javascript-Befehl: partylist

Hallo nochmal,

zwar funktioniert das jetzt, wenn man Antwortet oder eine Mail neu erstellt, das ein bestimmte Name aus der Benutzerliste im "Von"-Feld vor eingetragen steht, allerdings soll das nicht bei allen CRM-Usern so sein.
Also wenn sich User X angemeldet hat und eine Mail beantworten möchte soll der Code nicht angewandt werden.
Aber ich hab keine Ahnung wie ich im Code schreiben soll, das er die GUID überprüfen soll und dann entscheidet.
Wer weiß da einen Rat oder die richtige Codeanweisung für GUID Überprüfung?

Das hier klappt so nicht.
if (UserID != '16769C93-F5DF-DA11-8E80-0003FFD90CC3')
das ist der Code der im Moment funktioniert:
    if(crmForm.FormType == 1)
{
//Create an array to set as the DataValue for the lookup control.
   var lookupData = new Array();
//Create an Object add to the array.
      var lookupItem= new Object();
//Set the id, typename, and name properties to the object.
      lookupItem.id = '{000DIE00-00US-ER00-0ID0-000HIER0000}';
      lookupItem.typename = 'systemuser';
      lookupItem.name = 'Vor eingetragener User';
// Add the object to the array.
      lookupData[0] = lookupItem;
// Set the value of the lookup field to the value of the array.
      crmForm.all.from.DataValue = lookupData;
   alert('der Absender wurde automatisch auf "[email protected]" gesetzt')
}


Re: Javascript-Befehl: partylist

Ich habe zwar nicht so richtig das Problem verstanden, aber wie man an den aktuellen Benutzer herankommt, steht hier: http://ronaldlemmen.blogspot.com/2006/05/finally-there-show-and-hide-fields.html


AW: Re: Javascript-Befehl: partylist

[quote user="JuergenBeck"] [...] aber wie man an den aktuellen Benutzer herankommt, steht hier: http://ronaldlemmen.blogspot.com/2006/05/finally-there-show-and-hide-fields.html[/quote]

Hallo.

Ich hätte noch eine ergänzende Frage:
Ja, wie man die aktuelle UserID erhält wird ja in obgen Link beschrieben.
Ich würde gerne ergründen wie man den Namen des aktuellen Benutzers auslesen kann?

Besten Dank und Grüße...

Julius


AW: Re: Javascript-Befehl: partylist

http://www.developerfood.com/getting-username-from-guid-in-on-change/microsoft-public-crm-developer/ac651b40-3bbb-4169-bf00-127855168931/article.aspx

MfG
lh0rst


AW: Re: Javascript-Befehl: partylist

Vielen Dank für das Posten des Links,

aber der Code führt bei mir leider zu Fehlern.

Ich beschäftige mich noch nicht so Lange mit dem CRM und bin auch ansich kein Java Programmierer, Daher folgende Frage:  Kann der folgende Code überhaupt im OnSave Event der entität ausgeführt werden? Und wie muss dieser modififiziert werden, dass er auch wirklich funktioniert?

var xml = "" +
"" +
"
xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"
xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">" +
" " +
"
xsi:type=\"q1:QueryExpression\"
xmlns=\"http://schemas.microsoft.com/crm/2006/WebServices\">" +
" systemuser" +
" " +
" " +
" systemuserid" +
" fullname" +
"
" +
"
" +
" false" +
" " +
" And" +
" " +
" " +
" systemuserid" +
" EqualUserId" +
"
" +
"
" +
"
" +
"
" +
"
" +
"
" +
"";


var xmlHttpRequest = new ActiveXObject("Msxml2.XMLHTTP");


xmlHttpRequest.Open("POST", "/mscrmservices/2006/CrmService.asmx", false);
xmlHttpRequest.setRequestHeader("SOAPAction","http://schemas.microsoft.com/crm/2006/WebServices/RetrieveMultiple");
xmlHttpRequest.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
xmlHttpRequest.setRequestHeader("Content-Length", xml.length);
xmlHttpRequest.send(xml);


var doc = xmlHttpRequest.responseXML;
var user = doc.selectSingleNode("//BusinessEntity");


var userId = user.selectSingleNode("systemuserid").text;
alert(userId);


crmForm.all.new_act_user.DataValue = user.selectSingleNode("fullname").text;
alert(userName);



UND was hat folgender Hinweis zu bedeuten?
 
"For some reason the scripting did not like the long strings between the +s or there were
hidden carriage returns. I put each line in quotes and added +s at the end of
each line and now it works great."


Besten Dank für die Hilfe!

Julius




Re: Javascript-Befehl: partylist

Zur Beruhigung... der obige Code funktioniert in der Tat nicht. Auf der Webseite werden diverse Zeichen nicht angezeigt. Geht man stattdessen in den HTML-Code der Webseite so sind alle Zeichen wieder da, wie beispielsweise das Attribut "<q1:Attribute>".