Get sum of fields using ListData.svc or API?

I want to make a call to ListData.svc or the API through a URL and get a sum of a field back based on the filter criteria I send.  Is there a way to do this?

Hi,
There would not be such aggregation function in CAML query or OData query when sending a restful request:
http://msdn.microsoft.com/en-us/library/office/ms467521(v=office.15).aspx
http://msdn.microsoft.com/en-us/library/office/fp142385(v=office.15).aspx#sectionSection7
As a workaround, I would suggest you do the math in client side with the data retrieved.
Thanks
Patrick Liang
Forum Support
Please remember to mark the replies as answers if they
help and unmark them if they provide no help. If you have feedback for TechNet
Subscriber Support, contact [email protected]
Patrick Liang
TechNet Community Support

Similar Messages

  • Tutorial on how to update list items using ListData.svc

    Can you please point me to a tutorial which shows how to update a list item using listdata.svc and C#?
    Sorry if this is FAQ.
    I have found articles on read list... but I haven't found anything on update a list item.
    val it: unit=()

    when i try this I get an error 500
    I created an ASP.NET web application that allows the user to modify data that is stored in SharePoint I rather not go into the reasons why this application was created but focus more on why doesn't the listdata.svc allow me to update a task item that was
    created by a workflow collect data from user action.
    1. The workflow creates the item.
    I collect the item and update the item using the below code. This is not an OOTB approval workflow that is just the name I used. When I get to save changes I received the following error code.
    Dim getApprovalItem As ExpenseApprovalRuleBasedTasksItem = spContext.ExpenseApprovalRuleBasedTasks.Where(Function(i) i.Id = Pam.ApprovalItemID).FirstOrDefault
    If String.IsNullOrEmpty(getApprovalItem.AuditorApprovalValue) Then
    getApprovalItem.AuditingComments = approvalComments
    Select Case approvalDecision
    Case "Approved"
    getApprovalItem.AuditorApproval = ExpenseApprovalRuleBasedTasksAuditorApprovalValue.CreateExpenseApprovalRuleBasedTasksAuditorApprovalValue("Approved")
    getApprovalItem.AuditorApprovalValue = "Approved"
    Case "Rejected"
    getApprovalItem.AuditorApproval = ExpenseApprovalRuleBasedTasksAuditorApprovalValue.CreateExpenseApprovalRuleBasedTasksAuditorApprovalValue("Rejected")
    getApprovalItem.AuditorApprovalValue = "Rejected"
    End Select
    getApprovalItem.Outcome = "Completed"
    getApprovalItem.Status = ExpenseApprovalRuleBasedTasksStatusValue.CreateExpenseApprovalRuleBasedTasksStatusValue("Completed")
    getApprovalItem.StatusValue = "Completed"
    getApprovalItem.Complete = True
    spContext.UpdateObject(getApprovalItem)
    spContext.SaveChanges()
    End If

  • How to create a document folder using ListData.svc

    Hi All,
    I've recently been put on a project where I need to use the REST services (ListData.svc) to retrieve and add documents to the document library. It all has been smooth sailing until I hit the point where I want to save a document in a path that doesn't exist.
    I get an error if I try to save a file where the folder structure doesn't exist. I then went about it a different way trying to create the folder structure first. This also didn't work and I get an error message saying that the entity type is marked with the
    MediaEntry attribute but no save stream was set for the entity. Not too sure what set for the save stream if I'm just adding a folder.
    So my question is can a file be added to a folder structure that doesn't exist where it automatically creates the folders. If not can the service create folders?
    Some sample code I've been using:
    var folder = new SampleDocumentLibraryItem();
    folder.Name = "Sample";
    folder.Title = "Sample";
    folder.ContentType = "Folder";
    folder.Path = "/sample/folder1/folder2";
    spContext.AddToSampleDocumentLibrary(folder);
    spContext.SaveChanges();
    Thanks in advance,
    Damo

    Hi All,
    Finally managed to figure this one out. For anyone who needs source on how to create a document folder. Some sample source is below...
    var folder = new DocumentLibraryItem();
    folder.Name = "Folder Name";
    folder.Title = "Folder Name";
    folder.ContentType = "Folder";
    folder.Path = path;
    spContext.AddtoDocumentLibrary(folder);
    spContext.SetSaveStream(folder, stream, false, folder.ContentType, folder.Path + folder.Name + "|0x0120009BCC19899CEBC6468FF4EEAC7B8CF4F5"
    spContext.SaveChanges();
    So the important differences in the code above. The content type of the object and stream MUST be set to "Folder". I'm not sure why but you still need to set the save stream to be a valid stream even though you're only adding a folder. So just keep the stream
    open and then pass "true" to close it when you actually save the file. The other important element as noted from the URL's in the previous comments is you need to add a "|" + Content Type ID of a folder. You'll be able to get this ID by visiting the rest service
    for an existing document library and view source to see the actual content type id for a folder.
    Thanks everyone for your help,
    Damo

  • Determine Email of the person in the people field using JSOM or REST API

    Hi,I have to build below HTML dynamically. The source to build this is a sharepoint list that has a people field in it.Can I use JSOM or REST API to do this? if so, can anyone help with some examples?<a href='mailto:[email protected],[email protected]'>Write email</a>
    techie

    Hi,
    The following code for your reference:
    <script src="http://code.jquery.com/jquery-1.11.1.min.js" type="text/javascript"></script>
    <script type="text/javascript">
    $(function () {
    var array=new Array();
    var requestUri = _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/getbytitle('CustomList')/items?$select=EmployeeId";
    // execute AJAX request
    $.ajax({
    url: requestUri,
    type: "GET",
    headers: { "ACCEPT": "application/json;odata=verbose" },
    success: function (data) {
    var dataResults = data.d.results;
    for(var i=0;i<dataResults.length;i++){
    if(dataResults[i].EmployeeId!=null){
    for(var j=0;j<dataResults[i].EmployeeId.results.length;j++){
    array.push(dataResults[i].EmployeeId.results[j]);
    //remove the duplicated id
    var employeeIds=$.unique(array);
    //get the employee email by user id
    var emails=getEmailsByIDs(employeeIds);
    //add to send mail div
    $("#SendMail").append("<a href='mailto:"+emails+"'>Send Email</a>");
    error: function () {
    //console.log("Failed to get details");
    function getEmailsByIDs(employeeIds){
    var emails=new Array();
    var requestUri = _spPageContextInfo.webAbsoluteUrl + "/_api/web/siteusers?$select=Id,Email";
    // execute AJAX request
    $.ajax({
    url: requestUri,
    type: "GET",
    headers: { "ACCEPT": "application/json;odata=verbose" },
    async: false,
    success: function (data) {
    var dataResults=data.d.results;
    for(var i=0;i<dataResults.length;i++){
    for(var j=0;j<employeeIds.length;j++){
    if(dataResults[i].Id!=null&&dataResults[i].Id==employeeIds[j]&&dataResults[i].Email!=null){
    emails.push(dataResults[i].Email);
    error: function () {
    //console.log("Failed to get details");
    return emails;
    </script>
    <div id="SendMail">
    </div>
    Thanks,
    Dennis Guo
    TechNet Community Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
    [email protected].
    Dennis Guo
    TechNet Community Support

  • Help , How to get data from database using recordset with UI API

    I want to get a data from database
    when I want to create recordset i notice that UI API didn't has record set
    so I created recordset using DI API (SAPbobscom.recordset and SAPbobscom.company)
    ======================================================
    Dim oCompanyUI As SAPbouiCOM.Company <<UI API
    Dim oRecSet As New SAPbobsCOM.Recordset << DI API
    Dim oCompanyDI As New SAPbobsCOM.Company << DI API
    '=====================================================
    oCompanyDI.Connect
    Set oRecSet = oCompanyDI.GetBusinessObject(BoRecordset)
    oRecSet.DoQuery ("SELECT T0.CardCode, T0.CardName FROM OCRD T0")
    SBO_Application.MessageBox oRecSet.Fields.Item(1).Value
    ======================================================
    but I got an error it said "you are not connected to company"
    I'm really don't have an idea about how to get a data from using UI API (exp I want to get a date or costumer code)
    can someone help me please, I really need it
    Thanks

    you need a single sign on
            Dim oDICompany As SAPbobsCOM.Company
            Dim sCookie As String
            Dim sConnStr As String
            Dim ret As Integer
            oDICompany = New SAPbobsCOM.Company
            sCookie = oDICompany.GetContextCookie
            sConnStr = SBO_Application.Company.GetConnectionContext(sCookie)
            If oDICompany.Connected Then
                oDICompany.Disconnect()
            End If
            ret = oDICompany.SetSboLoginContext(sConnStr)
            If Not ret = 0 Then
                SBO_Application.MessageBox("set Login Context failed!")
                Exit Sub
            End If
            ret = oDICompany.Connect()
            If Not ret = 0 Then
                SBO_Application.MessageBox("Company Connect failed!")
            End If

  • How can I get selected EXCEL area using java script office API (v 1.0)

    Hello everyone,
    I need to get values of specified area in an excel sheet using java Script Office API. For an example,
    A1:A7 row load into array using JS. 

    And you posted to a C++ forum, not a JavaScript or Excel forum.... why? 
    Visual C++ MVP

  • Sum Currency Fields using Workflow Field Update

    Trying to have a workflow rule that updates a field "Total Payments" when any of the "Payment" amount fields change.
    Created the workflow rule like this:
    PRE('<cPayment1_ITAG>')<>[<cPayment1_ITAG>] OR PRE('<cPayment2_ITAG>')<>[<cPayment2_ITAG>] OR PRE('<cPayment3_ITAG>')<>[<cPayment3_ITAG>]
    And the Update Field Value rule as follows:
    =[<cPayment1_ITAG>]+[<cPayment2_ITAG>]+[<cPayment3_ITAG>]
    But it doesn't want to work. Should I use "FieldValue" function for the update rule?
    Thanks,
    Dan

    That worked perfectly, thanks Mani!
    I've seen where people have mentioned using the "=" sign or no "=" sign but I'm not sure most people understand the proper use of when to use it versus when not to. Can anyone elaborate on the cases when an equal sign should be used versus when it shouldn't be used?
    I personally would like to have a bit more knowledge regarding these types of idiosyncrasies of the syntax.
    Dan

  • Listdata.svc - shows column names?

    I have leveraged the REST service using listdata.svc many times. However, we are having trouble with one site in particular.  Cannot use REST with it and getting all sorts of errors in Visual Studio. This post is not about VS or C#, however, just about
    what should be in the REST schema period. I am seeing tons of huge node values when looking at the listdata.svc in a browser.  It appears these are a combination of the list name and the column name.  I didn't think column names showed up at all,
    just list names?
    For example:
    <collection
    href="InvestmentPortfolioAnticipatedProjectTeamSizeFTESContractorsCustomersVendorsEtc">
    <atom:title>InvestmentPortfolioAnticipatedProjectTeamSizeFTESContractorsCustomersVendorsEtc</atom:title>
    I found that Investment Portfolio is a legit list in the site, but the rest of that value is a column name.  Other lists do not have columns listed in this schema when viewing from the browser.  Can someone explain to me why this is happening?
    Thanks

    Hi,
    If you access http://siteurl/_vti_bin/listdata.svc, the preceding url returns all the lists in XML format. There will be no column name included in a <collection> node for normal lists, except when
    there is Choice column in this list.
    There will be extra <collection> nodes listed as the format below for the lists which contains Choice column:
    <collection href="ListnameColumnname">
    <atom:title>ListnameColumnName</atom:title>
    </collection>
    It seems this extra <collection> node is for internally use only which is not designed to be exposed to developers.
    I would suggest you submit a feedback to the Office Developer Platform if there any expectation about the documentation about SharePoint APIs:
    http://officespdev.uservoice.com/
    It is a place for customers provide feedback about Microsoft Office products. What’s more, if a feedback is high voted there by other customers, it will be promising that Microsoft Product Team will take it into consideration when designing the next version
    in the future.
    Regards,
    Rebecca Tu
    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
    [email protected]

  • Can't get a delimiter between Reapting Table Fields using the Double Eval formula.

    I have a problem in setting up the "Double Eval" formula, for a repeating table field.
    Background:
    I have a multiple-selection list box in an InforPath (2010) form. I want to concat all selected values in the list box and display them in a textbox with ";" as delimiter. I've gotten so far that with rules running when the list box is updated, the
    textbox content is updated listing the IDs of the selected items (I'm not sure yet if I want to display the IDs or make a lookup for the true text values, but that's another issue for later...).
    Problem:
    My problem is that I can't get the delimiter between the values. They are all listed in sequence with the ";" delimiter only at the end.
    I use the following formula ("Required" is the repeating field)
    eval(eval(Required; 'concat(., ";")'); "..")
    and get the following result:
    What I want to get into the comments text box is the string "684;239;91;".
    Any ideas what's wrong with my formula?
    (Using InforPath 2010 on a list published to SharePoint 2010.)

    Additional info that maybe is important to know:
    The multiple-selection list box is getting its values from a secondary data connection using a web service call:
    http://MySite/_vti_bin/ListData.svc/MyList?$filter=((CT%20eq%20'Product')%20and%20(CompGroup%20ne%20'OS'))&$orderby=Title
    The selections in my list box is yet stored in the field "Required" in a different SharePoint list, we can call it "BaseList", at the same site ("MySite").
    So to summerize:
    List 1: MySite/MyList
    Fields: CT, CompGroup, Title
    List 2: MySite/BaseList
    Fields: Required
    The different lists have more fields of course, but no need to list them all.

  • Get all the field's value of addressbook entry using c++ api

    How can i get all the field values of address book entry in groupwise using c++ api.

    You should be able to do that via the Token API. There is an AddressBookGetEntry method. You could createsome sort of AddressbookEntry class that fetches (via iteration over the defined ABFields) all the innformation.

  • HT5624 Why in my email ( the one on my ipod5 that I use with my apple ID) when I get emails about my use of my apple ID to use a service in the from field it has my fathers name and when I click on it it shows his contact info ????

    Why in my email ( the one on my ipod5 that I use with my apple ID) when I get emails about my use of my apple ID to use a service in the from field it has my fathers name and when I click on it it shows his contact info ???? I also set up my apple ID with a new email account and also I signed up for iCloud but used the same apple I'd email and password but it gave me a I cloud email! I did activate the favorites in my email . Noticed the from field has my fathers name and contact and it is a notification about me using my apple ID to sign in to FaceTime! Something is messed up, not sure how or why???

    i didn't read a lot of your 2nd paragraph, but it seems like the password is the issue, right?
    do a true clean install
    reboot your machine and hold down command+option+r, you should see a spinning globe - if you don't see the globe or anything that reads internet recovery, shut down and try again
    at menu, chose disk utility and once there, find your HD on the left side, select the physical name and erase it as mac journaled
    exit disk utlity
    at menu, choose install OSX
    this time, when it asks for a password just hit continue, it will let you complete without a password
    you should be able to get into your laptop, now figure out what password you'll be able to use with your kb issue

  • How to prevent a number field from getting summed?

    I want to display the # of clients per a certain ID number. (In order to show the duplicate records by setting a filter in the # of clients field). However, this works if the ID number is a text field... but it doesn't work if the ID number is a metric of client... or number. It gets summed up, I get the total, and the % of clients turns to be 1.
    Any ideas?
    Thanks

    Example:
    I have 3 clients:
    Column A
    55
    55
    44
    21
    I want the following output:
    55 | 2
    I get the desired result by adding a second column (# of clients) and creating a filter to get results only if the value is > 2.
    The problem is when "Column A" is a number field. If it is a number field, I get total sum of the records (55+55+44+21) and a value of "1" if I add the # of clients column.
    Is it clearer now? ideas?

  • In Existing SSIS package how we can call _vti_bin\listdata.svc service using script

    we have already used SSIS package using SharePoint List adapter but its not working properly... Can you will pref-are sharepoint list adapter for business purpose?  
    so we have decided to go with web service (_vti_bin\listdata.svc) and my main challenge is writing script i have to access list oblect from the webservice.
    Can
    you guide me how to write script ..how we can add service into script ...any examples for
    accessing SharePoint list( From Sql server to SharePoint list update)
    Regards,
    Anoop Nagappan

    We have already used SSIS package using SharePoint List adapter but its not working properly... Can you will pref-are sharepoint list adapter for business purpose?  
    so we have decided to go with web service (_vti_bin\listdata.svc) and my main challenge is writing script i have to access list oblect from the webservice.
    Can
    you guide me how to write script ..how we can add service into script ...any examples for
    accessing SharePoint list( From Sql server to SharePoint list update)
    Regards,
    Anoop Nagappan

  • Http Bad Request when using /_vti_bin/listdata.svc in excel or tableau

    hi all,
    I followed a guide from tableau that teaches us how to connect odata(sharepoint list data) but it keeps giving me HTTP bad request.
    When i tried to access my list  using http://myserverIP/_vti_bin/ListData.svc
    from the browser with credential, I am able to access the listdata and see the data from other lists. I decided to try connecting to excel instead but it gives me the same error, HTTP bad request. What am I doing wrong? Does the problem comes from
    access rights or?
    Can anyone help or guide me? Thank you

    Hi Leonard,
    Thanks for posting your query, you can refer one of my blog to create and configure a WCF service in SharePoint.
    http://dharmendrablogs.blogspot.in/2013/02/rest-wcf-service-in-sharepoint-2010.html
    And, another blog is
    http://dennis.bloggingabout.net/2006/11/09/WCF-Part-4-Make-your-service-visible-through-metadata/
    Hope this is helpful to you. If this works, Please mark it as Answered.
    Regards,
    Dharmendra Singh (MCPD-EA | MCTS )
    Blog URL : http://sharepoint-community.net/profile/DharmendraSingh

  • Need help with summing column when using if-then-else

    Using logic
    <?xdofx:if INVOICE_BILL_AMT_IN_INV_CURR is null then INVPROC_BILL_AMOUNT else INVOICE_BILL_AMT_IN_INV_CURR end if?> for column field.
    Having trouble summing the column using the logic above.
    Any suggestions would be very much appreciated.
    Thanks,
    Nancy

    Thanks Tim,
    That worked. Got rid of my error. However, if the field is null (=''), I get a total.
    11.05 + 1429.70 = 1440.75
    If the not null (!='') I am not getting a total.
    103.74 + 173.13 =
    BTW, recently took XML class. Leta Davis highly recommended your blog and I have gotten a lot of great tips from it.
    Thanks,
    Nancy

Maybe you are looking for

  • Add SC Item Detail View as an usage in my own WDA?Can you guide me?

    As the title,I want to add SC detail view in my own WDA Viewcontainer. And use the item GUID to control the data. I tried to add the componet '/SAPSRM/WDC_UI_SC_OIF_CA' in the 'Used componet' and bind the 'IV_L_FPC_OIF_CA' in the view container. But

  • Incoming mail sound does not sound- is activated in preferences

    Started after taking headphone jack out of back of Mac. iTunes plays, can hear sounds from Second Life, MSN Messenger, but incoming/outgoing sounds in Mail and iChat are gone. Activated/enabled in preferences in each app but don't play for incoming m

  • Difference between report OF MCSI & MC+E

    Hallo Experts As per my client the output of the report mcsi ( while using info structure S725 , Monhly sales) & MC+E for the month of Jan to March should match. But both the values are not matching & there is a huge difference between the two. I am

  • ITunes Connect error

    When I try to apply for iTunes Connect for Apps distribution, it takes me to the iTunes connect login page. I try to login but it gives me an error: "Apple ID does not have permission to access iTunes Connect." Can you please help me?

  • Searchable text in DPS

    Can anyone tell me how to make text searchable in a DPS publication from Indesign? I am working with educational content creators and they have asked if it is possible to have the text in the DPS document searchable and to make "Study notes" from the