web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Dynamics 365 Community / Forums / Finance forum / No resources were foun...
Finance forum

No resources were found when selecting for update

(0) ShareShare
ReportReport
Posted on by

I am getting issue in updating customer postal address. 

Below in my method to updating customer postal address. 

string addressLocationId = "000004773";
string company = "USMF";
string customerAccountNumber = "usmf_US-P010";

CustomerPostalAddress customerPostalAddress = _context.CustomerPostalAddresses.AddQueryOption("cross-company", "true").Where(x => x.DataAreaId == company &&
x.AddressLocationId == addressLocationId && x.CustomerAccountNumber == customerAccountNumber).FirstOrDefault();


DataServiceCollection<CustomerPostalAddress> dataServiceCollection = new DataServiceCollection<CustomerPostalAddress>(_context);

dataServiceCollection.Add(customerPostalAddress);

 

customerPostalAddress.AddressDescription = "Test address.";
  

DataServiceResponse response = null;
try
{
_context.UpdateObject(customerPostalAddress);
response = _context.SaveChanges(SaveChangesOptions.PostOnlySetProperties);

}
catch (Exception ex)
{
Console.WriteLine(ex.Message + ex.InnerException);
}


I am getting below error. 

\"message\":\"No resources were found when selecting for update.\",
\"type\":\"Microsoft.Dynamics.Platform.Integration.Services.OData.ODataArgumentException\",\"stacktrace\":\"
at Microsoft.Dynamics.Platform.Integration.Services.OData.Update.UpdateManager.GetEntityForUpdate(IQueryable query, EntityType entityType) ...... 

I have the same question (0)
  • Martin Dráb Profile Picture
    237,959 Most Valuable Professional on at

    Tell us what you have found when you debugged your code before giving up and coming here.

    First of all, gets customerPostalAddress filled in?

  • Community Member Profile Picture
    on at

    Yes I am getting correct result in customerPostalAddress using above code.

  • Martin Dráb Profile Picture
    237,959 Most Valuable Professional on at

    Is this all what you can tell us about your debugging? For instance, have you tried it with another entity, another property, without cross-company, without PostOnlySetProperties and so on?

    By the way, it seems that you never use dataServiceCollection variable, therefore let me simplify your code to this:

    string addressLocationId = "000004773";
    string company = "USMF";
    string customerAccountNumber = "usmf_US-P010";
    
    CustomerPostalAddress customerPostalAddress = _context.CustomerPostalAddresses
        .AddQueryOption("cross-company", "true")
        .Where(
            x => x.DataAreaId == company
            && x.AddressLocationId == addressLocationId
            && x.CustomerAccountNumber == customerAccountNumber
        ).FirstOrDefault();
    
    customerPostalAddress.AddressDescription = "Test address.";
    
    try
    { 
        _context.UpdateObject(customerPostalAddress);
        _context.SaveChanges(SaveChangesOptions.PostOnlySetProperties);
    }
    catch (Exception ex)
    {
        Console.WriteLine(ex.Message + ex.InnerException);
    }

    You'll likely be able to simplify it further after you test what influences the behavior and what doesn't.

  • Community Member Profile Picture
    on at

    Hi Martin,

    I have also tried above code earlier (Without dataservicecollection) but still I am getting same issue.

    PostOnlySetProperties is only used with dataServiceCollection. :)

    While debugging above code I am not getting any issue except _context.SaveChanges() method.

    customerPostalAddress object is correctly loaded and I have check all attributes they have correct value.

    SaveChanges() method showing innerexception i.e.

    "No resources were found when selecting for update".

  • GP Development community Profile Picture
    135 on at

    Hi Gaurav Singhvi,

    For the ODATA update we need to use all the Entity key value for the Filter or in Where condition. In your code customerPostalAddress.Effective is seems to be missing. Try using the below code part, will see

    CustomerPostalAddress customerPostalAddress = _context.CustomerPostalAddresses
        .AddQueryOption("cross-company", "true")
        .Where(
            x => x.DataAreaId == company
            && x.AddressLocationId == addressLocationId
            && x.CustomerAccountNumber == customerAccountNumber
    && x.Effective == *Give the Effective Date Here*
    ).FirstOrDefault();

    Thanks

    Praveen

  • Community Member Profile Picture
    on at

    Hi Praveen,

    I have tried with the Effective date but still I am getting the same error. i.e. "No resources were found when selecting for update"

               string addressLocationId = "000004773";

               string company = "USMF";

               string customerAccountNumber = "usmf_US-P010";

               DateTime dt = Convert.ToDateTime("6/28/2018 11:12:34 AM +00:00");

               CustomerPostalAddress customerPostalAddress = _context.CustomerPostalAddresses

                   .AddQueryOption("cross-company", "true")

                   .Where(

                       x => x.DataAreaId == company

                       && x.AddressLocationId == addressLocationId

                       && x.CustomerAccountNumber == customerAccountNumber

                       && x.Effective == dt

                   ).FirstOrDefault();

               //customerPostalAddress : I am getting proper object with correct values.

               customerPostalAddress.AddressDescription = "Test address.";

               try

               {

                   _context.UpdateObject(customerPostalAddress);

                   _context.SaveChanges();

               }

               catch (Exception ex)

               {

                   Console.WriteLine(ex.Message + ex.InnerException);

               }

  • Mahesh Wankhade Profile Picture
    90 on at

    Hi All ,

    Any luck with issue , I am also facing same error with address.

  • Gogo Lazarovski seavus Profile Picture
    25 on at

    Hi,

    Also I have the same issue deleting record.

    Has any suggestion how to use cross-company, in the context saving the data??

    "message":"No resources were found when selecting for update.","type":"Microsoft.Dynamics.Platform.Integration.Services.OData.ODataArgumentException"

    Thank You

  • Suggested answer
    Gogo Lazarovski seavus Profile Picture
    25 on at

    You can solve the issue using oData web api services for F&O avoiding, .net library odata.client and autogenerated file ODataClient.cs.

    Here is my sample of deleting record that exist in different company of the current user:

    string fromDate = ar.From.ToString("yyyy-MM-ddThh:mm:ssZ");

                   string toDate = ar.To.ToString("yyyy-MM-ddThh:mm:ssZ");

                   string sessionUrl = $"/data/Table_AdSv(dataAreaId='{ar.DataAreaId}',PersonalNumber='{ar.PersonalNumber}',DateFrom={fromDate},DateTo={toDate},AbsenceType_AdSv='{ar.Type}')?cross-company=true";

                   string GetUserSessionOperationPath = string.Format("{0}{1}", ClientConfiguration.Default.UriString.TrimEnd('/'), sessionUrl);

                   var request = HttpWebRequest.Create(GetUserSessionOperationPath);

                   request.Headers[OAuthHelper.OAuthHeader] = OAuthHelper.GetAuthenticationHeader(true);

                   request.Method = "DELETE";

                   request.ContentLength = 0;

                   using (var response = (HttpWebResponse)request.GetResponse())

                   {

                       using (Stream responseStream = response.GetResponseStream())

                       {

                           if(response.StatusCode == HttpStatusCode.NoContent)

                           {

                               return true;

                           }else

                           {

                               using (StreamReader streamReader = new StreamReader(responseStream))

                               {

                                   throw new Exception($"DeleteAbsence ApiStatusCode: '{response.StatusCode.ToString()}' Error: {streamReader.ReadToEnd()}");

                               }

                           }

                       }

                   }

  • Anitha Eswaran Profile Picture
    312 on at

    Hi Gaurav,

    I tried using POSTMAN , But before attempting Update I executed GET request for the postal Address and then pass the values to the update.

    My GET request is url/.../CustomerPostalAddresses eq '1234' &cross-company=true

    I copy the details of the entity keys from the above response to the update request.

    PATCH request is url/.../CustomerPostalAddresses(dataAreaId='usmf',CustomerAccountNumber='1234',CustomerLegalEntityId='usmf',AddressLocationId='000074583',Effective=2020-10-29T12:56:21Z)

    Try if this helps.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard > Finance

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans