githubbob42 / mingle2github2

0 stars 1 forks source link

Set and Clear a lookup causes sync failure #4609

Closed githubbob42 closed 7 years ago

githubbob42 commented 7 years ago

Mingle Card: 4952 Steps to Reproduce

| | |
|-|-|
|**Version #**| |
|**Hardware**| |
|**OS**| |
|**Browser**| |
|**Username**| |
|**Password**|Use LastPass|
|ORG ID| |
|User ID| |
|RayGun Error ID| |

Key Energy Sandbox

  1. In mobile start creating a new ticket
  2. Select something for the SWR lookup
  3. Clear the SWR lookup
  4. Finish creating the ticket
  5. Sync

Expected Result

Ticket should be created in back office

Actual Result

Ticket create fails because the SWR entry has a null value

{
    "eventname": "model:event-queued",
    "payload": {
        "url": "/services/data/v38.0/sobjects/FX5__Ticket__c",
        "method": "POST",
        "body": {
            "FX5__Created_in_Mobile__c": true,
            "FX5__SyncID__c": "d45af0f3-f412-42f3-9dca-6cd438468fdd",
            "FX5__Sync__c": false,
            "FX5__Ticket_Date__c": "2017-03-14",
            "FX5__Tracking_Number__c": "T-B0F-DE6-A6EE",
            "FX5__Work_Start_Date__c": "2017-03-14T20:16:15.000+0000",
            "Manual_Signature_or_Stamp__c": false,
            "eSignature_Captured__c": false,
            "Picture_Stamp__c": false,
            "Job_Class__c": "Completion",
            "Email_Ticket_for_Approval__c": false,
            "Copy_Ticket__c": false,
            "Entered_in_KeyOps__c": false,
            "Attachments_Exported__c": false,
            "Start_Time__c": "00:15",
            "Stop_Time__c": "00:45",
            "attributes": {
                "type": "FX5__Ticket__c",
                "url": "/services/data/v38.0/sobjects/FX5__Ticket__c/FX5__Tracking_Number__c/T-B0F-DE6-A6EE"
            },
            "FX5__Job__c": "a0k21000000oYaCAAU",
            "RecordTypeId": "01231000001AhUTAA0",
            "FX5__Status__c": "a1221000001WVd4AAG",
            "Asset__c": "a0g21000001WeWrAAK",
            "SWD__r": null,
            "Work_Description__c": "abc"
        },
        "sobject": "FX5__Ticket__c",
        "syncid": "d45af0f3-f412-42f3-9dca-6cd438468fdd"
    },
    "eventId": 1489522636421
}

What actually happens?

Analysis

This only happens on new objects as we are passing the entire object into the event-queue and thus setting the relationship field (SWD__r) to null which is not valid to set on a lookup field on a new object for salesforce.  On existing objects, we only set the field (SWD__c) to null which is valid for updates.

When writing to a reference (in saleforce-data-context), check if the object is new (scope.isNew) and if so, set the shallowObject to undefined (as that is it’s initial state value), otherwise, set it to null.

Related Cards

Test Plan

Selenium > checklist.js > Test 7. Ticket - lookup fields (#4952)

githubbob42 commented 7 years ago

Matthew Todd : 03/23/2017 17:07 CDT ...Ticket - the Ticket makes it to Back Office. It was failing when testing on the current Master version of 4.0.1.3657.

githubbob42 commented 7 years ago

Matthew Todd : 03/23/2017 17:05 CDT Test Result : Passed PRBuild: 4.0.1.pr2303 on 9.1.3 AdminUser: qaadmin@test4.com FieldUser: qafield@test4.com Hardware : Surface Pro 3 OS : Windows 10 Pro Browser : Chrome 57.0.2987.110 (64-bit) URL : https://hunterpeak.herokuapp.com TestCase: Create a Ticket on Job (4952) Test Notes : Adding a new lookup field, after you select an item and then clear it, the Job now makes it to Back Office.

githubbob42 commented 7 years ago

Pull Request #2303