• Shraddha_Khanapure
  • NEWBIE
  • 10 Points
  • Member since 2016
  • Senior Salesforce Developer

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 6
    Replies
We got contact extract from production and there is a field of data type rich text area which is been used to store contact image. Data loading team uploaded the data to sandbox and we were able to display the images in our lightning component but image do not displayed on community when investigate we found out image source is pointing to production i.e. (img src="https://production.salesforce.com/servlet/servlet.ImageServer?id=01541000002yi92AAA&oid=00D41000000XUZ3") instead of sandbox. When we tried to upload the image manually the image src displays as (img src="/sfsites/c/servlet/rtaImage?eid=0035400000HkFAR&feoid=00N4100000eTIwO&refid=0EM5400000050K5")
Can anyone explain me
1. how image of production url is getting displayed in lightning component and on contact detail record but not on community?
2. How can we resolve this issue ?
I tried to search for solution but no luck. I appreciate your help.
Thank you in advance.

I'm trying to populate the opportunity owner name in the TASK on a new custom field called Opp Owner. Should this be in process builder? Or is there a formula I can use? I'm trying to avoid using Apex Triggers.

Thanks!
Hi,

I created tabs for some components and I want to use some components in detail page, but unable to do that in Salesforce mobile app. 
  • August 21, 2019
  • Like
  • 0
Hi Experts!

I have a requirement to create the record and when it gets created I want to show that details in the same page by forming the section in Lightning web component.

Thanks in advance
 

Hey guys,

 

I have a class that allows users to submit json objects and parses them in to sObjects. It's simpel for strings, and numbers because apex handles those when being assigned to objects. 

 

I'm having trouble finding a good way to handle dates/datetimes.

 

 

 

if(records.size() > 0) {
                        sObjectType s = Schema.getGlobalDescribe().get(sObjectType);
                        list<sObject> objects = new list<sObject>();
                        for(object o : records) {
                            //instantiate a new sObject based on the type specified in the objectMap
                            sObject newRecord = s.newSObject();
                            
                            //Now cast the field mapping definition that the user has passed in to create the record
                            map<string,object> recordDefinition = (map<string,Object>)o;
                            for (string field : recordDefinition.keySet()) {
                                
                                newRecord.put(
                                    field,
                                    recordDefinition.get(field)
                                );
                            }
                            
                            system.debug('UDBG::::insertRecords looped through record and created newRecord: ' + newRecord);
                            objects.add(newRecord);
                        }
                        if(!objects.isEmpty()){
                            insert objects;
                        }
                        responseMessage = objects.size() + ' records inserted';
                        
                    } 

 

Above is my current snippet. Notice that it's all dynamic - the class will allow the user to specify the sObject type - so I figure that out.

 

The "records" variable in the first for loop is an array submitted from json - eg:

[
    {"Name" : "myNewRecordName0", "Type__c" : "MyType0"},
    {"Name" : "myNewRecordName1", "Type__c" : "MyType1"}
]

 I feel like there might be some magic method that can help me out with the next bit... Currently I manually create a new sObject record based on the dynamic type:

 

sObject newRecord = s.newSObject();

Then I just convert each json record to a map, and do a "put" for each field and value with:

                            map<string,object> recordDefinition = (map<string,Object>)o;
                            for (string field : recordDefinition.keySet()) {
                                
                                newRecord.put(
                                    field,
                                    recordDefinition.get(field)
                                );
                            }

 

 

This all works fine until I hit a date, or date time... I have to submit those as strings - eg:

[
    {"Name" : "myNewRecordName0", "Type__c" : "MyType0", "Date__c" : "23-12-2013"},
    {"Name" : "myNewRecordName1", "Type__c" : "MyType1", "Date__c" : "23-12-2013"}
]

 At which point I get the error: 

Illegal assignment from String to Date

 

 

 

SO. Long story short - is there a way I can simply cast my "record" object inteligently to my sObject type? Something like: 

for(object o : records) {
    //instantiate a new sObject based on the type specified in the objectMap
    sObject newRecord = s.newSObject();
    JSON.castSObject(newRecord, o);
}

 

That way I can avoid having to do field type checks on each field and having to cast those individually to the proper field types like "date.valueof("10-10-2013")"

 

 

  • December 05, 2013
  • Like
  • 0