User Select in ASP (reports)

Hi I have some code that worked perfectly fine in 7.1 but after upgrading to 7.3SP2 I have an issue where a user select field (without metadata) fails to display the list of users however works perfectly fine in 7.1. Haven't tested on 7.2.

<!-- #include file ="../sagecrmreports.js"-->
<%
var Head = "<HTML><HEAD><LINK REL=stylesheet HREF=/"+sInstallName+"/Themes/ergonomic.css><META http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">";
var Body = "<BODY>";
var EndBody = "</BODY></HTML>";

Response.Write(Head);
Response.Write(Body);

/////////Your Code Starts Here////

if (CRM.Mode<Edit) CRM.Mode = Edit;

Container=CRM.GetBlock("container");
Container.DisplayButton(Button_Default) = false;

var ParamBlock = CRM.GetBlock("EntryGroup");

var UserSelect = CRM.GetBlock("Entry");
UserSelect.Caption = "User(s): ";
UserSelect.EntryType = 22;
UserSelect.FieldName = "param_users";
UserSelect.Size = 10;
ParamBlock.AddBlock(UserSelect);

Container.AddBlock(ParamBlock);

Container.AddButton(eWare.Button("Run", "nex.gif", "javascript:document.EntryForm.submit();"));
Container.AddButton(eWare.Button("Cancel", "Cancel.gif", eWare.URL(1400)));

////////You Code Ends Here///////////
%><SCRIPT LANGUAGE="JavaScript">
function onLoadStuff() {
var tmp;
tmp = document.EntryForm.param_users;
tmp.multiple = true;
document.EntryForm.param_usersInput.onchange();
}
window.attachEvent("onload",onLoadStuff);
</SCRIPT>
<%
Response.Write(Container.Execute());

Response.Write(EndBody);

%>

  • 0

    Gavriel

    There are several "problems".

    If we use the technique

    Response.Write(Container.Execute());

    When this generates the HTML it excludes much of the hidden part of the screen that includes the script that generates the clients side CurrentUser object and the arrays that contain the list of Users. This is the array that the User Select field needs.

    But if generate the page using

    CRM.AddContent(Container.Execute());

    Response.Write(CRM.GetPage());

    It will create the needed client side objects but it will make the page look like a normal Sage CRM page with the top content and menu options. To suppress this we would need to get the page to behave like a 'Popup'. We can do this by automatically reloading the page with the flag.

    /////////Your Code Starts Here////

    if (Request.QueryString("PopupWin")!="Y")

    {

    Response.Redirect(Request.ServerVariables("PATH_INFO")+"?"+Request.ServerVariables("QUERY_STRING")+"&PopupWin=Y")

    }

    See below my partial rebuild.

    /////////Your Code Starts Here////

    if (Request.QueryString("PopupWin")!="Y")

    {

    Response.Redirect(Request.ServerVariables("PATH_INFO")+"?"+Request.ServerVariables("QUERY_STRING")+"&PopupWin=Y")

    }

    //Block Create

    if (CRM.Mode==View)

    {

    CRM.Mode = Edit;

    }

    var myBlock = CRM.GetBlock("entrygroup");

    //EntryBlock - User select

    var customUserEntryBlock = CRM.GetBlock("entry");

    with(customUserEntryBlock)

    {

    EntryType = 22

    FieldName = "custom_userid";

    Caption = "User:";

    CaptionPos = CapTop;

    Size= 1;

    NewLine = false;

    }

    var myContentBlock = CRM.GetBlock("content");

    myContentBlock.contents = "";

    myBlock.AddBlock(customUserEntryBlock);

    CRM.AddContent(myBlock.Execute());

    CRM.AddContent(myContentBlock.Execute());

    Response.Write(CRM.GetPage());