Using JQuery deferred objects with JSOM

Hi,
I have written following query to execute a JSOM call using Jquery Deferred objects.
But It is not working. I am getting following error:
Uncaught TypeError: Cannot read property 'get_current' of undefined .  Can anyone help what is wrong here?
<script type="text/javascript">
ExecuteOrDelayUntilScriptLoaded(getrelatedProjects, "sp.js");
function getrelatedProjects() {
    var dfd = $.Deferred(function () {
       var clientcontext = new SP.ClientContext.get_current();
        var list = clientContext.get_web().get_lists().getByTitle("Roadmap");
        var camlQuery = new SP.CamlQuery();
        this.collListItem = list.getItems(camlQuery);
        clientContext.load(collListItem);
        context.executeQueryAsync(
           function () {
               var listItemCollection = list.getItems(camlQuery);
               dfd.resolve(listItemCollection);
           function () {
               dfd.reject(args.get_message());
    return dfd.promise();
getrelatedProjects().done(function (listColl) {
    var listItemEnumerator = listColl.getEnumerator();
    // do something with the list
    while (listItemEnumerator.moveNext()) {
        var oListItem = listItemEnumerator.get_current();
        listItemInfo += '\nID: ' + oListItem.get_id() +
            '\nTitle: ' + oListItem.get_item('Title');
    alert(listItemInfo.toString());
</script>
       

I have been trying for help since one week on this issue. Here is my requirement. Can someone just help me modify this code. All I am looking for is to execute getStatus(project) synchronously.
// JavaScript source code
var roadmapList;
var collListItem;
var dashboardList;
var statusItem;
ExecuteOrDelayUntilScriptLoaded(loadRoadMap, "sp.js");
function loadRoadMap() {
    var currentCtx = SP.ClientContext.get_current();
    var currentWeb = currentCtx.get_web();
    this.roadmapList = currentWeb.get_lists().getByTitle('Roadmap');
    var camlQuery = new SP.CamlQuery();
    this.collListItem = roadmapList.getItems(camlQuery);
    currentCtx.load(collListItem);
    currentCtx.executeQueryAsync(
        Function.createDelegate(this, this.onQuerySucceeded),
        Function.createDelegate(this, this.onQueryFailed)
function onQuerySucceeded(sender, args) {
    var listItemInfo = '';
    var listItemEnumerator = collListItem.getEnumerator();
    while (listItemEnumerator.moveNext()) {
        //alert("Success");
        var oListItem = listItemEnumerator.get_current();
        var projectUrl = oListItem.get_item('ProjectURL').get_url();
        listItemInfo += '<tr><td>' + oListItem.get_item('Roadmap_x0020_Project')
+ '</td><td>' + getStatus(projectUrl) + '</td></tr>';
        $('#statusTable').append($(listItemInfo));
function onQueryFailed(sender, args) {
    alert('Request failed. ' + args.get_message() +
        '\n' + args.get_stackTrace());
function getStatus(project) {
    var crossSiteContext = new SP.ClientContext("http://myanothersite.com/it/");
    var crossSiteWeb = crossSiteContext.get_web();
    this.dashboardList = crossSiteWeb.get_lists().getByTitle('Dashboard');
    var projectQuery = new SP.CamlQuery();
    projectQuery.set_viewXml("<View><Query><Where><Eq><FieldRef
Name=\'Project\'/>" +
        "<Value Type=\'URL\'>" + project + "</Value></Eq></Where></Query>"
+
        "<RowLimit>1000</RowLimit></View>");
    this.statusItem = dashboardList.getItems(projectQuery);
    crossSiteContext.load(statusItem);
    crossSiteContext.executeQueryAsync(
        Function.createDelegate(this, this.onStatusQuerySucceeded),
        Function.createDelegate(this, this.onStatusQueryFailed)
function onStatusQuerySucceeded(sender, args) {
    var projectItemInfo = '';
    var projectItemEnumerator = statusItem.getEnumerator();
    while (projectItemEnumerator.moveNext()) {
        var curstatusItem = projectItemEnumerator.get_current();
        projectItemInfo += '\nID: ' + curstatusItem.get_id() +
            '\nStatus: ' + curstatusItem.get_item('Project_x0020_Status').Label;
function onStatusQueryFailed(sender, args) {
    alert('Request failed. ' + args.get_message() +
       '\n' + args.get_stackTrace());

Similar Messages

  • Using multiple UIWebView objects with a Tab Bar Controller.

    So, I'm pretty new to this cocoa touch language and seem to be hitting a road block.
    I have an application that will use a Tab Bar Controller as a navigation. Each tab will display a different UIWebView object that's been linked to their own URL's. I can't for the life of me figure out how to get past the first UIWebView. If they're all the same object, with the same name, how can I set a different url for each??
    I've been going nuts over this for the past few hours and can't find any documentation online so any help would be AMAZING. Thank you very much.
    Message was edited by: thenameisjesse

    If they're all the same object, with the same name, how can I set a different url for each??
    They're not the same object. You alloc and setup each UIWebView independently.
    UIWebView is just a view so set it up the same way you would if you had a tabbar with multiple views.
    The default template has 2 views as I recall. Change the UIViews to UIWebView. As you switch them in set the URL and have it load.

  • Iphone apps using flex remote objects with CF???

    I am used to making web applications that use flex remote objects to interact with CF.
    Is it possible to use remoting from an iphone app cross compiled using flash builder to interact with Cf remoting on a remote server?

    Interseting, config files always seem to me like a strange way to do things.
    I'm not exactly sure what you mean by this, but by default, that's how remoting works in Flex - you have channels and destinations defined on your server, and your compiler points to your config files and reads those values. So it's a little extra work to define them in AS instead.
    Can you give me any tips on authenticating requests to cfc's from mobiles and how to protect my servers once I exposes cfc's to apps not hosted on the same server as CF?
    There isn't really anything mobile-specific you need to do here. Exposing CFCs isn't any different than exposing CFM files that are accessed via a browser. You can use the standard CF session management and CF authentication (cflogin) - there are some examples available by Googling "coldfusion cflogin flex remoting".
    Dave Watts, CTO, Fig Leaf Software

  • Can a Servlet be used for Storing Objects with both JSP and JSF used on it?

    Hi,
    Pages I have:
    SearchEmployee.jsp
    This page has a search engine that search out the Employee. This Employee Object will be stored inside a Servlet(controller) for future references by other pages. I used JSP, html tags for forms, and request.getParameter() to built this search engine.
    Problem:
    I have a JSF Form that wants to DISPLAY the employee which I have found in my Search Engine. How can I get the JSF's value="#{Controller.employeeObj.name}" to get the value from the object?
    This seems logical as my JSF form is just retrieving the stored object in the Controller. I currently cant seem to output it

    The servlet shouldn't be used to store ANY data, let alone data to be accessed by other sevlets. Put the object into the Session object.

  • Use of OLE Objects with the Publisher tool

    Our company is trying to put user guides, screen shots, report examples, etc. on the BPMN diagrams that we are creating. I am wondering if anyone has figured out a good way to get multi-page documents to show up as icons which can be clicked from the Business Process Publisher web client. The normal OLE's work decently for users with BPA installed, but they are not hyperlinked in the Web Client. One option I tried was simply displaying the OLE not as an icon, but simply as it's own diagram in BPA, so it would be available that way, but the problem there is it only shows the first page, and it doesn't allow it to be linked to from an icon, it only uses the assignment icon. Any ideas? Best practices?
    -Chris

    HI Chris
    there are link attributes which let you browse and choose a file as link.
    when you create a web export, the files choosen as links for attributes are also exported on Business publisher.
    One of the three profiles you choose when doing a web export support files being copied on BP server
    Cheers

  • How to use user defined object with linked button

    Hi experts
    Can I use user defined table data with linked button. If yes then how. plz give me sample examples.
    Regards
    Gorge

    If you have an UDO in your form, or any other, the FormDataLoad eventhandler should be used.
    Take care, it is not inside the eventhandler.
    for VB:
    Select SBO_APPLICATION in the classes, and select FormDataLoad event
    Private Sub SBO_Application_FormDataEvent(ByRef BusinessObjectInfo As SAPbouiCOM.BusinessObjectInfo, ByRef BubbleEvent As Boolean) Handles SBO_Application.FormDataEvent
    in C#
    Add a new eventhandler as
    // declaration
    SBO_Application.FormDataEvent += new SAPbouiCOM._IApplicationEvents_FormDataEventEventHandler(ref SBO_Application_FormDataEvent);
    // eventhandler:
    public void SBO_Application_FormDataEvent(ref SAPbouiCOM.BusinessObjectInfo BusinessObjectInfo, out bool BubbleEvent)

  • Using the ComboboxColumn Object with a grid

    Hello everyone,
    I am writing an addon dealing with user tables, it basically loads data from user tables into a grid and then lets the user perform several operations on it, my problem is that whennever a field contains valid values, the grid displays it as a regular field, and does not add a combobox to choose the valid values from.
    My question is : is it possible to display the valid values list on a grid cell, or do i have to switch to a matrix in order to do that.
    EDIT : I Found a work arround for my issue , which is to declare a ComboboxColumn object to which i would assign the grid's column containing valid values but i'm not sure about how to do it : here's a sample of my code
    oRecordSet.DoQuery("select * from Table")
    Dim oComboBoxColumn As SAPbouiCOM.ComboBoxColumn
    Dim oCounter as integer
    oCounter= 0
    While oCounter < oRecordSet.Fields.Count
           If oRecordSet.Fields.Item(oCounter).ValidValues.Count <> 0 Then
                 oGrid.Columns.Item(oRecordSet.Fields.Item(oCounter).Name.ToString).Type  
                  =BoGridColumnType.gct_ComboBox
                  oComboBoxColumn = oGrid.Columns.Item(oCounter)
                    ComboVVF(oComboBoxColumn, oRecordSet)
    /* ComboVVF ( Combo Valid Values Filler) is a sub which fills a given combobox with valid values from a recordset */
           End If
           oCounter += 1
    End While
    Kind regards
    Amin.

    Hi Amin,
    That's the correct way to do it. Unfortunately we don't have at our disposal a method to fill the combo box directly from a Table/Column (Something like the LoadFromSeries method).
    Regards,
    Vítor Vieira

  • Use Shared Local Object with Javascript

    Hi to everybody!
    I have to make a javascript component that have to take some
    data from a Shared Local Object;What I have to do in order to use
    the Shared Local Object in javascript? It maybe that I have to
    create an ActionScript file in which I use the Shared Local Object
    and than import that file in Js?
    Furthermore, do you know if it possible to lanch a waba
    application (is a java application for pocket pc and pda ) from a
    flash application?
    And if yes, What I hava to do?
    Thanks

    Have you downloaded and read the Acrobat SDK yet?  That's your starting point.

  • Using LabVIEW OOP Objects with TestStand 2010

    I need to use labview classes in Teststand 2010. I am not able to pass reference between Labview and Teststand.

    Or leave it in Labview and use an action engine.
    http://forums.ni.com/t5/LabVIEW/Community-Nugget-4-08-2007-Action-Engines/m-p/503801?view=by_date_as...
    That's what I have done.
    Regards
    Ray Farmer

  • How to use neutralzone object with alarm object?

    I need to monitor a tank level for alarm conditions.  I have created an alarm object so the user can specify values for the lolo, lo, hi, and hihi.  This works fine, except if the tank level hovers around an alarm level setting, too many alarm records are generated.  The Lookout Help page for the alarm object says to use a neutralzone object to filter out the minor fluctuations, but I can't find any details on how.  So how do I do this?  Can I use one alarm object with one neutralzone object for the four alarm settings, or one alarm object with four neutralzone objects, or four alarm and neutralzone object pairs?  How do I connect them?
    Many thanks,
    Ken

    Another method would be to add a delay before alarming using a DelayOn timer.  
    Ryan's suggestion would work, but if the process requires decimal precision you cannot use that method.
    Mike 
    Forshock - Consult.Develop.Solve.

  • How can I use a COM object that does not have a type library?

    Hello,
    I've created a com server in python for which I do not have a type library. I am able to call functions for this application in Python, TCL, I'm sure VB, etc. without the type library.
    Must I have a type library registered to use this COM object with Labview? I was hoping I could simply supply the name to the refnum (or the GUID) then call functions by passings strings to the invoke node. This does not seem to be possible - am I missing something?
    In the event that I cannot use a com server without a type library. Any recommendataions on how to create one? I'm wondering if I can use the same GUID and create a shell in LabWindows which generates the IDL/TBD file I need for Labview to see my
    com server.
    Any help is greatly appreciated.
    73,
    Timothy

    Timothy Toroni wrote:
    > Thanks for the info, however their example is labview server and
    > python client. I'm going the other way. It's good to know about
    > LabPython though...
    >
    > As of now, it seems to be there is no way to use a COM object without
    > a type library from inside LabView.
    Yes that is true. LabVIEW needs that to configure the Property and
    Methode Nodes correctly. Otherwise it would need to have a special
    Property and Method Node with a configuration dialog similar to the Call
    Library Node, but a LOT more complicated. Not sure many people could
    make use of that, and it would be a very tiring experience trying to get
    things setup in that way, by going through the edit, test, and crash
    cycle over and over again.
    Rolf Kalberm
    atter
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • View Object with User Defined Type input

    I am trying to use a View Object with a query that requires a user defined object as an input parameter.
    I have the query working with a PreparedStatement, but would like to use a View Object.
    When I use the PreparedStatement, I prepare the user defined type data like this:
    // get the data into an object array
    Object[] wSRecObjArr = wSRec.getObjectArray();
    // set up rec descriptor
    StructDescriptor WSRecDescriptor = StructDescriptor.createDescriptor("WS_REC",conn);
    // populate the record struct
    STRUCT wSRecStruct = new STRUCT(WSRecDescriptor,conn,wSRecObjArr);
    Then I can use this in the PreparedStatement like this:
    OraclePreparedStatement stat = null;
    ResultSet rs = null;
    stat = (OraclePreparedStatement)conn.prepareStatement("Select test_pkg.test_function(?) FROM DUAL");
    stat.setSTRUCT(1, wSRecStruct);
    rs = stat.executeQuery();
    I would like to do the same process with a View Object instead of the PreparedStatement.
    My question is "How do I create the input objects"?
    I obtain the View Object from the Application Module using findViewObject(). I don't actually have a connection object to pass into the StructDescriptor.createDescriptor method.
    I have tried just using Java Object Arrays (Object[]) to pass the data, but that gave an error:
    oracle.jbo.SQLStmtException: JBO-27122: SQL error during statement preparation.
    Any help or pointers are greatly appreciated.
    Thank you.
    Edited by: 942120 on May 1, 2013 8:45 AM
    Edited by: 942120 on May 1, 2013 8:46 AM
    Edited by: 942120 on May 1, 2013 9:05 AM
    Edited by: 942120 on May 1, 2013 9:06 AM

    Custom domains are the way to go.
    When I try to pass custom domains that represent my user defined types - it works.
    However, one of the functions requires a table of a user defined type be passed in.
    I tried creating a domain of the table type. It forces me to add a field during creation (in JDEV), so I tried adding a field of type Array of Element of the domain representing the user defined type.
    I populate the table by setting the field I created, but the table is empty in PL/SQL (TEST_TAB.COUNT = 0).
    I also tried passing the oracle.jbo.domain.Array object, but that produced an error:
    java.sql.SQLException: ORA-06553: PLS-306: wrong number or types of arguments in call
    I also tried passing Object[], but that produced an error:
    oracle.jbo.SQLStmtException: JBO-27122: SQL error during statement preparation.
    How do I properly create, and pass an domain that represents a table of a user defined type?
    When I use a OraclePreparedStatement, I can pass a oracle.sql.ARRAY using stat.setARRAY.
    Thank you for the help you have provided, and any future advice.
    JDEV 10.1.2.3
    JDBC 10.2.0.5
    Edited by: 942120 on May 13, 2013 7:13 AM
    Edited by: 942120 on May 13, 2013 7:16 AM

  • View Object with ?-style query parameters - best place to locate code

    I am using a View Object with ?-style parameters, with a JClient applet. The query
    paramters are filled in from user-entered data:
    viewObject.setWhereClauseParams(parms); /* parms is the user data*/
    viewObject.executeQuery();
    Right now the above code is located in the applet. Is it more efficient to code this as a
    method in the ViewObject (or Application Module), then call the method from the Client with
    the supplied parameters?
    I'm still unclear as to how network traffic is affected by running code like this on the client
    as opposed to the server. Maybe someone could point me to a comprehensive dic that covers this.
    Thanks

    I am using a View Object with ?-style parameters, with a JClient applet. The query
    paramters are filled in from user-entered data:
    viewObject.setWhereClauseParams(parms); /* parms is the user data*/
    viewObject.executeQuery();
    Right now the above code is located in the applet. Is it more efficient to code this as a
    method in the ViewObject (or Application Module), then call the method from the Client with
    the supplied parameters?
    I'm still unclear as to how network traffic is affected by running code like this on the client
    as opposed to the server. Maybe someone could point me to a comprehensive dic that covers this.Yes, the above two methods will turn into two network roundtrips.
    You may run your application in Events profiler to get a list of 'roundtrip' calls being made in your app.
    Select Project-Settings->Profiler panel->Events panel.
    Deselect all events, expand BC4J events and select REMOTE_METHOD_CALL event type (1016). Then Profile your app using the event profiler and the profiler will list all the calls that BC4J roundtrip calls. You may use this info to narrow down the roundtrips by batching up operations in an exported method etc.
    Thanks

  • How to create a Document Set in SharePoint 2013 using JavaScript Client Side Object Model (JSOM)?

    Hi,
    The requirement is to create ""Document Sets in Bulk" using JSOM. I am using the following posts:-
    http://blogs.msdn.com/b/mittals/archive/2013/04/03/how-to-create-a-document-set-in-sharepoint-2013-using-javascript-client-side-object-model-jsom.aspx
    http://social.msdn.microsoft.com/Forums/sharepoint/en-US/1904cddb-850c-4425-8205-998bfaad07d7/create-document-set-using-ecma-script
    But, when I am executing the code, I am getting error "Cannot read property 'DocumentSet' of undefined "..Please find
    below my code. I am using Content editor web part and attached my JS file with that :-
    <div>
    <label>Enter the DocumentSet Name <input type="text" id="txtGetDocumentSetName" name="DocumentSetname"/> </label> </br>
    <input type="button" id="btncreate" name="bcreateDocumentSet" value="Create Document Set" onclick="javascript:CreateDocumentSet()"/>
    </div>
    <script type="text/javascript" src="//ajax.aspnetcdn.com/ajax/jQuery/jquery-1.7.2.min.js"> </script>
    <script type="text/javascript">
       SP.SOD.executeFunc('sp.js','SP.ClientContext','SP.DocumentSet','SP.DocumentManagement.js',CreateDocumentSet);
    // This function is called on click of the “Create Document Set” button. 
    var ctx;
    var parentFolder;
    var newDocSetName;
    var docsetContentType;
    function CreateDocumentSet() {
        alert("In ClientContext");
        var ctx = SP.ClientContext.get_current(); 
        newDocSetName = $('#txtGetDocumentSetName').val(); 
        var docSetContentTypeID = "0x0120D520";
        alert("docSetContentTypeID:=" + docSetContentTypeID);
        var web = ctx.get_web(); 
        var list = web.get_lists().getByTitle('Current Documents'); 
        ctx.load(list);
        alert("List Loaded !!");
        parentFolder = list.get_rootFolder(); 
        ctx.load(parentFolder);
        docsetContentType = web.get_contentTypes().getById(docSetContentTypeID); 
        ctx.load(docsetContentType);
        alert("docsetContentType Loaded !!");
        ctx.executeQueryAsync(onRequestSuccess, onRequestFail);
    function onRequestSuccess() {       
        alert("In Success");
        SP.DocumentSet.DocumentSet.create(ctx, parentFolder, newDocSetName, docsetContentType.get_id());
        alert('Document Set creation successful');
    // This function runs if the executeQueryAsync call fails.
    function onRequestFail(sender, args) {
        alert("Document Set creation failed" + + args.get_message());
    Please help !!
    Vipul Jain

    Hello,
    I have already tried your solution, however in that case I get the error - "UncaughtSys.ArgumentNullException: Sys.ArgumentNullException:
    Value cannot be null.Parameter name: context"...
    Also, I tried removing SP.SOD.executeFunc
    from my code, but no success :(
    Kindly suggest !!!
    Vipul Jain

  • Problem with using multiple Entity Objects in a view Object.

    Hi
    Thank you for reading my post
    I have create 3 Business components for 3 of my database tables and now
    I must add 3 tables in a View object so i used Jdeveloper Wizard to create the View Object.
    -I Add Entity Objects which are business components to this view (In Step 2 of the Create Vview Object wizard).
    -In step 3 that I add Attributes all my attributes are marked as Transient
    Can some one explain why it happens?
    I need one of those tables to be updateable and two other tables are not updateable.
    What should should i do to achieve this?
    I should say that tables does not have any database relation (Foreign Key I Mean).
    Thanks.

    Hi user505214
    When you created your VO, on selecting the second EO, you'll note at the bottom of the same page on the wizard/editor, checkboxes for updatable or by reference. By default reference is checked and this will make your second EO's attributes transient.
    In the JDeveloper Developer's Guide for 4GL/Forms programmers, the following sections outline the difference between updatable or by reference:
    7.5 Including Reference Entities in Join View Objects
    27.9 Creating a View Object with Multiple Updatable Entities
    Make sure to read 27.9 if updatable is what you want as it indicates you may need to add some additional code.
    Hope this helps.
    CM.

Maybe you are looking for

  • How do u delete iCloud account or CHANGE the email address?

    Long story short, I ended up having to restore to factory settings my iphone.  I had planned on restoring one of the backups that I had done through iTunes.  (Yes, I now know to backup through iCloud so please do NOT suggest that -.-) but it kept tel

  • Can a PDF file in landscape mode have two pages open at once

    I notice when I use ibooks to read a pdf document on my ipad that in normal mode it woks just like a book with one page open, but when I turn to landscape mode, the document just greatly reduces in size, and centers on the screen, where as a book ope

  • If I have 11.0.03, do I need 9.5.5?

    Adobe keeps sending me a message to upgrade Adobe Reader to 9.5.5, but I already have 11.0.03. Isn't that the latest version? Why does Adobe want me to go backward? I'm using a white late 2008 MacBook, running OS 10.6.8.

  • How to create the PROFORMA INVOICE

    Hi all,          How to create the PROFORMA INVOICE. T-code? Regards, T.Muruganantham

  • How to fax using Oracle and OAS40

    Hi I am using Oracle 8i and OAS 40. I wanted to fax documents online using OAS 40. By any chance any body knows how to do it, please share with me regards manoj null