• Anshuma Yadav
  • NEWBIE
  • 50 Points
  • Member since 2022

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 15
    Questions
  • 5
    Replies

I am eliminating dependency of apex from LWC component and want to get custom objects from salesforce org to migrate custom objects into another org using SOAP callout in LWC.

var myHeaders = new Headers();
myHeaders.append("SOAPAction", " login");
myHeaders.append("Content-Type", " text/xml; charset=utf-8");
myHeaders.append("Cookie", "BrowserId= ; CookieConsentPolicy=0:0; LSKey-c$CookieConsentPolicy=0:0");
var raw = '<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:urn=\"urn:enterprise.soap.sforce.com\">'
          +'<soapenv:Body>'
          +'<urn:login>'
          +'<urn:username>myusername</urn:username>'
          +'<urn:password>mypassword</urn:password>'
          +'</urn:login>'
          +'</soapenv:Body>'
          +'</soapenv:Envelope>';
var requestOptions = {
method: 'POST',
headers: myHeaders,
mode:'no-cors',
body: raw,
redirect: 'follow'
};
fetch("https://login.salesforce.com/services/Soap/c/57.0", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));

 

I am writing the below code for the same but it's not working.

 connectedCallback(){
            const messageCallback  = (response) => {
                console.log('New message received3 : ', JSON.stringify(response));
                getRecordList({recordId : this.recordId})
                    .then(result => {
                        this.wrapperList2 = result;
                        console.log('result1 ',JSON.stringify(this.wrapperList2));
                    })
                    .catch(error => {
                        console.log('Errorured2:- '+error.body.message);
                    });
            }
           
            console.log('Inside connected callback4');
            subscribe(this.channelName, -1, messageCallback)
            .then(response =>
                        {
                            console.log('****Subscription request fulfilled****5 ', JSON.stringify(response.channel));
                        })        
        }


Thankyou!!
I have created an LWC component. After updating particular record details of the object(lead)  I am getting updated field records of that object(lead) through apex in the LWC component.
And I don't want to include the Aura component to complete this requirement.
I need to compare the values of these maps.

 Map<String, Object> fieldsToValueNew = lw.newValues.getPopulatedFieldsAsMap();
            for (String fieldName : fieldsToValueNew.keySet()){
                System.debug('field name is ' + fieldName + ', new value is ' +
                             fieldsToValueNew.get(fieldName));
            }
            Map<String, Object> fieldsToValueOld = lw.oldValues.getPopulatedFieldsAsMap();
            for (String fieldName : fieldsToValueOld.keySet()){
                System.debug('field name is ' + fieldName + ', old value is ' +
                             fieldsToValueOld.get(fieldName));
            }
If the value is updated in the account object record(updation in field of the record, change in ownership of the record, added child to that record, deletion of that record), then I want to fetch the history of that record and want to store every updated record in another custom History__c object. how do we can achieve this?
I need to compare the values of these maps.

 Map<String, Object> fieldsToValueNew = lw.newValues.getPopulatedFieldsAsMap();
            for (String fieldName : fieldsToValueNew.keySet()){
                System.debug('field name is ' + fieldName + ', new value is ' +
                             fieldsToValueNew.get(fieldName));
            }
            Map<String, Object> fieldsToValueOld = lw.oldValues.getPopulatedFieldsAsMap();
            for (String fieldName : fieldsToValueOld.keySet()){
                System.debug('field name is ' + fieldName + ', old value is ' +
                             fieldsToValueOld.get(fieldName));
            }