• Baku Jain
  • NEWBIE
  • 0 Points
  • Member since 2023

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 5
    Replies
Working on the new Salesforce Lightning web components. I am trying to get the multidimensional array sorted in javascript. I have a trackable array, it has a few columns, i want the data sorted by the total buildings value. Here is what I have done so far, no errors, but not getting the expected results.
@track bc = [];
@wire(getCityStats) cityStats({ data }) {
    if (data) {
      for (let i = 0; i < data.length; i++) {
        if (data[i].sumchans__Province_Code__c == 'BC') {
          this.bc.push(data[i]);
        }
      }
      sortCityByNumberOfBldgs(this.bc);
}
}
  sortCityByNumberOfBldgs(province) {
    province.sort(function(a,b) {
      return a[4]-b[4]
    });
  }

Here is the SOQL in the Apex controller:
SELECT Name,sumchans__Province_Code__c,
        (select sumchans__Penetration__c,sumchans__Total_Buildings__c from sumchans__City_Stats__r) FROM sumchans__CITY_MASTER__c
This is how the data gets displayed when I run the above query and this is the data that is getting stored in the trackable bc array above.
User-added image
 
I have a requirement to share a note with multiple accounts. My first issue I was trying to solve is being able to store the notes data in variables then create new records based off that data. I have a trigger on ContentDocumentLink that passes info off to a class. 

Problem is, if I save the note before it auto saves, everything works. If I let the record auto save, I dont get the body of the note. 
 
trigger trasnferNotes on ContentDocumentLink (after insert) {
    
    string relatedID;
    String documentID;
    
    //Get the current ID for the note
    if (Trigger.isAfter) {
        if (Trigger.isInsert) {
            for(ContentDocumentLink cdl : Trigger.New) {
                relatedID = cdl.LinkedEntityId;
                documentID = cdl.ContentDocumentId;
                transferNotesClass db = new transferNotesClass(relatedID, documentID);
            }
        }
    }
    
}
 
global class transferNotesClass {
    
    global String noteID;
    global String contentDocumentID;
    global String cvID;
    
    global transferNotesClass(String relatedID, String documentID) {
        
        try {
            
            noteID = relatedID;
            contentDocumentID = documentID;
            
            System.debug('Class Note ID: ' + noteID);
            
            
            //Getting the ID from ContentVersion
            List<ContentVersion> cv = New List<ContentVersion>([select id from ContentVersion 
                                                                where ContentDocumentId = :contentDocumentID]);
            for(ContentVersion cv1 : cv) {
                cvID = cv1.Id; 
            }
            
            //Getting the Content Note by passing the above ID to ContentNote
            List<ContentNote> contNote = New List<ContentNote>([select Content, ContentSize, CreatedById, CreatedDate, FileExtension, FileType, 
                                                                Id, IsDeleted, IsReadOnly, LastModifiedById, LastModifiedDate, LastViewedDate, 
                                                                LatestPublishedVersionId, OwnerId, SharingPrivacy, TextPreview, Title 
                                                                from ContentNote where LatestPublishedVersionId = :cvID]);
            
            for(ContentNote contNote1 : contNote) {
                Blob contentBlob = contnote1.Content;
                String contentString = contentBlob.toString();
                List<String> csvFileLines= contentString.split('\n');
                system.debug(csvFileLines);
                System.debug('Note Title: ' + contNote1.Title);
                //System.debug('Note Content: ' + csvFileLines);
            }
            
        }
        
        catch(DmlException e) {
            System.debug('The following exception has occurred: ' + e.getMessage());
        }
        
    }
    
}

 
Hi!
I registered with trailhead.
I’m an SDR looking to expand my Salesforce skill set. Let’s pretend I have none. Particularly looking for the basics around reporting, and any other trails that may be beneficial to spend some time with.
My goal is to have a competent understanding of SF to build my sales as I enter a closing role and the relevant tools in SF that will help me gain an advantage.
Thanks in advance!
Hi there :)

i'm currently working on an native Android app for my company and ran into some problems with Salesforce lately.

I hope i can find some help here.

What i want to achieve:
The company has a lot of Accounts in Salesforce with 3 important fields for the app: Name, Business (Workshop or Parts Dealer) and location(latitude, longitude)
I would like to show those Accounts(Workshops/Parts Dealers) as markers on a google map in my Android app based on a radius around the user's current location. So it would be more than sufficient to get the data as JSON or XML(i read about sObjects, which would be nice too)

The app will be freely available on Google Play Store and every user should be able to see all the Workshops/Parts dealers around the world.

The problem i'm facing is that i can't find a way to fetch the data inside my app without authenticating every user with a Salesforce-Login. 
Which API is the best to use in this case?

It would be so awsome if anybody could help me with this problem.

What i tried so far: 
- SalesforceMobileSDK: If i extend SalesForceApplication i always end up with the Salesforce-Login Screen.
It seems that every client has to be authenticated for API-calls to work. I tried using the method "peekUnauthenticatedRestClient", but this method only works on full path URL's(e.g. "https://api.spotify.com/v1/search?q=James%20Brown&type=artist"), which isn't really practically for my Use-case.

- I feel like i read nearly all docs about salesforce api, but can't quite get my head around how to solve this problem, although it seems like to be a pretty common use-case.  

- would a salesforce-apex method which would select all records inside a set radius around the user's location be accessable without authentication?

Thanks for your help in advance!

Roman

Hi,

 

I am following the book "Developement with the Force.com platform" by JasonOuelette.

When creating the Custom Objects, I did not check the box to be visible in a tab, and so I could not add this object to the Custom App I was creating. Now I have a created fields and relationships in the custom object. How do I add this Object to the Custom App?

 

thanks

Svidya

  • September 27, 2010
  • Like
  • 2