• Sumant Kuchipudi
  • NEWBIE
  • 30 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 3
    Likes Received
  • 0
    Likes Given
  • 33
    Questions
  • 20
    Replies
Hi,
I have lightning components that displays images from ContentVersion as thumbnails and also links, when I click on the image its directly downloading the image but I would like it to open as preivew or open the image in a new tab/window. please advice.
below is the current line that displays image thumbnails with link to open big
<aura:iteration items="{!v.items}" var="content">
	       <a href="/sfc/servlet.shepherd/version/download/'+{!content.id}" target="_blank"> <img src="/sfc/servlet.shepherd/version/download/'+{!content.id}" width="100" height="100"/> </a>
	    </aura:iteration>

 
Hi,
I have an object with 1.5 million records and I need to update couple of fields on all 1.5 m records by calling HTTP callout for each records, i.e. inside batch I need to call outside for 1.5 m times. Is that ok to run the query on all these records and invoke HttP callout? Is that feacible? whats the best procedure. 
Thank you very much.
Hi,
I have sandbox and we are cleaning up the data for fresh loads, we were able to bulk delete records(dataloader) on Standard and Custom objects but I can't find the way to delete the Content Bodies. All these content (files) recrods childs to Accounts, I think when we delete all Accounts these Contents should have been deleted but I still see the Content Bodies in Storage Usage page.
User-added image
 
Hi,
I have a trigger on an object that compares the new values with the existing and send email if new value comes for each record. When I tested with simeple UPSERT record it worked and whem I tested with an integration that calls upser bulk api, the trigger didn't invoke. Triggerns won't triggern on bulk api requests?
Hi, 
I have RestResource (httppost) that receives the data (JSON) from third party, they have bunch of members information which we need to upsert them into our system. if JSOn contains couple of records then fine but when they send 20 records then failing with "FATAL_ERROR|System.LimitException: Too many DML statements: 151". please see  below code. What is the best way to process those bunch of records? 
 
@RestResource(urlMapping='/ELPMData/*')
global with sharing class ELPMData {
	@httpPost
    global static String getMembersData(List<ELPMember> members){
        try{
            for (ELPMember elp: members){
                Bio bio = elp.bio;
                Account acc = new Account();
                acc.Name = bio.LastName+', '+bio.FirstName;
                acc.External_ID__c = bio.ID;
                acc.State__c = bio.State;
                acc.Type = 'Member';
                upsert acc External_ID__c;

                Contact con = new Contact();
                con.AccountId = acc.id;
                //Other contact fields mapping here
                upsert con External_ID__c;

                if (elp.ContactInformations != null){
                    List<Address__c> addrList = new List<Address__c>();
                    for (ContactInformation ci:elp.ContactInformations){
                        if (ci.AddressID != null && ci.AddressID != ''){
                            System.debug(' INSIDE ADDRESS '+ci.AddressID);
                            Address__c add = new Address__c();
                            add.AddressID__c = ci.AddressID;
                            //Other Address fields mapping here
                            addrList.add(add);
                        }
                    }
                    if (addrList.size()>0){
                        upsert addrList AddressID__c;
                    }
                }
                if (elp.Affiliations != null){
                    List<Affiliation__c> affilList = new List<Affiliation__c>();
                    for (Affiliation aff:elp.Affiliations){
                        if (aff.UniqueID != null && aff.UniqueID != ''){
                            Affiliation__c elpAffl = new Affiliation__c();
                            elpAffl.UniqueID__c = aff.UniqueID;
                            //Other Affiliation__c fields mapping here
                            affilList.add(elpAffl);
                        }
                        
                    }
                    if (affilList.size()>0){
                        upsert affilList UniqueID__c;
                    }
                }
                if (elp.Educations != null){
                    List<Education__c> eduList = new List<Education__c>();
                    for (Education edu:elp.Educations){
                        if (edu.InstitutionID != null && edu.InstitutionID != ''){
                            Education__c elpEdu = new Education__c();
                            elpEdu.InstitutionID__c = edu.InstitutionID;
                            //Other Education mapping here
                            eduList.add(elpEdu);
                        }
                    }
                    if (eduList.size()>0){
                        upsert eduList InstitutionID__c;
                    }
                }
                if (elp.Employments != null){
                    List<Employment__c> empList = new List<Employment__c>();
                    for (Employment emp:elp.Employments){
                        if (emp.UniqueID != null && emp.UniqueID != ''){
                            Employment__c elpEmp = new Employment__c();
                            elpEmp.UniqueID__c = emp.UniqueID;
                            //Other Employments mapping here
                            empList.add(elpEmp);
                        }
                    }
                    if (empList.size()>0){
                        upsert empList UniqueID__c;
                    }
                }
                
               
            }
        }catch(Exception e){
            System.debug('The following exception has occurred: ' + e.getMessage());
			return 'Integration FAILED, check with GU Admins';
        }
        return 'SUCCESS';
    }
    
    global class ELPMember {
        global Bio Bio {get;set;}
        global List<ContactInformation> ContactInformations {get;set;}
        global List<Affiliation> Affiliations {get;set;}
        global List<Education> Educations {get;set;}
        global List<Employment> Employments {get;set;}
    }
    global class Bio{
        //All Bio fields
    }
    global class Education {
        //All Education Fields
    }
    global class Affiliation{
        //All Affiliation fields
    }
    global class ContactInformation{
        //All Contact Fields
    }
    
    global class Employment{
        //All Employment fields
    }
    
}


 they may have 10000 members which we need to insert first time. 
Hi,
I have a process builder which calls Apex method (@InvocableMethod) and the apex method calls future callout, this process is failing with the below error. I have the code checking !system.isFuture() but still failing, not able to figure out.
Error element myRule_1_A1 (FlowActionCall).
An Apex error occurred: System.AsyncException: Future method cannot be called from a future or batch method: AddressValidateController.invokeAddressController(List)
Apex Code is below.
global with sharing class AddressValidateController {
    public static boolean isVerified = false;
   
	@InvocableMethod
    global static void validateAddressFromPB(List<Id> recIds){
       
        if(!system.isFuture() && !isVerified){
            integer count = 0;
            List<String> subList = new List<String>();
            for (Id recId:recIds){
                count+=1;
                subList.add(recId);
                if (Math.Mod(count, 100)==0){
                    invokeAddressController(subList);
                    subList=new List<String>();
                }
            }
            invokeAddressController(subList);
            isVerified = true;
        }
    }
    
    
	@future(callout=true)
    global static void invokeAddressController(List<Id> recIds){
        
               Address validation callout code here
    }
}

Please advice..!
 
I have created an external field in Account and have very simple code that upserts Account record.
below is the code
Account a = new Account();
a.name='Testing 99test9911';
a.Account_External_Id__c='99test99';
upsert a;
First time it creatd record but next time when I ran it failed (below is error), my environment is pretty much new (no triggers and no Workflows and no ProcessBuilders), I don't know how to fix this. Please advice
12:11:45:057 EXCEPTION_THROWN [4]|System.DmlException: Upsert failed. First exception on row 0; first error: DUPLICATE_VALUE, duplicate value found: Account_External_Id__c duplicates value on record with id: 0010t0000137DHM: []

 
I have custom object and it has Notes and Files related list, I want to restrict to one Note and one File for each custom record. Would that be possible?
HI,
I need to pull the all ContentDocumentLink recrods related to All Contacts (30K) and update LinkedEntityId (related to Contact) with new custom object record ids. while updating ContentDocumentLink record  I got below error
LinkedEntityIdUnable to create/update fields: LinkedEntityId. Please check the security settings of this field and verify that it is read/write for your profile or permission set.INVALID_FIELD_FOR_INSERT_UPDATEfalse
I'm using python script to do this (but apex solution is also fine). please check below code
query_result  = self.svc.query("select id from contact where Student__c=true and id='00336000014TJv9'")
            cnt=0
            contList=[]
            while True:
                for row in query_result[self.sf.records:]:
                    cnt+=1
                    contList.append(str(row[1]))
                if str(query_result[self.sf.done]) == 'true':
                    break
                query_result = self.svc.queryMore(str(query_result[self.sf.queryLocator]))
            for con in contList:
                links = self.svc.query("select id,ContentDocumentid from ContentDocumentLink where LinkedEntityId = '"+str(con)+"' limit 1");
                if (links!=None and len(links)>0):
                    for link in links[self.sf.records:]:
                        writer.writerow({'Contac_ID': str(con), 'Document_ID': str(link[3]),'Document_Linked_ID': str(link[1])})
                        emNotes = {
                            'type' : 'Em_Note__c',
                            'Contact__c' : str(con),
                            'Name' : str(link[3])
                        }
                        results = self.svc.create(emNotes )
                        emNotesID= results[0]
                        contentDocumentLink = {
                            'type' : 'ContentDocumentLink',
                            'id' : str(link[1]),
                            'LinkedEntityId' : str(emNotesID)
                        }
                        self.svc.update(contentDocumentLink); # I guess the error is here
Please advice


 
Hi,
I have a new profile and I need to use to around 200 Users but these are all with Force.com - App Subscription. I think we need to make Active=false and FederatonId is null, how can we do it for 200 users ? is it possible with dataloader? how can we do iti?
Hi,

I have below RestResourse and would like to give access to third party to gain access to this API through simple authentication, would it be possible? can I have an example on how to invoke this API from (Java/python)
@RestResource(urlMapping='/ELPData/*')
global with sharing class ELPRESTController {
	@httpPost
    global static String getFellowsData(List<ELPFellow> fellows){
        System.debug(' fellows '+fellows);
        return 'SUCCESS';
    }
    
    global class ELPFellow {

        global String FirstName { get; set; }
        global String LastName { get; set; }
        global String MiddleName { get; set; }
        global String Title { get; set; }
        global String Gender { get; set; }

    }
}

 
Hi,
I have below SOQL clause with Static Year and Month, is it possible to have dynamic values in those fields?
(
  ( 
     ( YEAR__c=2016 and Month__c='July' )  or 
     ( YEAR__c=2016 and Month__c='August' ) or 
     ( YEAR__c=2016 and Month__c='September' ) or 
     ( YEAR__c=2016 and Month__c='October' ) or 
     ( YEAR__c=2016 and Month__c='November' ) or  
     ( YEAR__c=2016 and Month__c='December' ) or 
     ( YEAR__c=2017 and Month__c='January' ) or 
     ( YEAR__c=2017 and Month__c='February' ) or 
     ( YEAR__c=2017 and Month__c='March' ) or 
     ( YEAR__c=2017 and Month__c='April' ) or 
     ( YEAR__c=2017 and Month__c='May' ) or 
     ( YEAR__c=2017 and Month__c='June' )
  ) 
  OR YEAR__c=null
)
)

 
I have BioRecord custom object which has Email, Phone, Status(picklist, Current, Former), Type (picklist, Home, Office, etc) and Record type (Phone and Email), we have integration that writes the data into this object. If a record is existed with a Type='Home' and recordtype='Phone' and if a new record comes with the same Type and same recordtype, I need to change the status of old record to 'Former'. 
i'm guessting that I can do it in Trigger but is there any alternate way we can change the Status of the record? 
I have a custom Address object, which has address fields, phone, and email fields. I'm wriging Process Builder on this object, with the following steps
1) Start the process, when a record created or edited
2) criteria.:
      Criteria for Executing Actions: Formula Evaluates to True
The formula should be on fields (Street, City , state, zipcode), one of these created, edited only the Process should trigger but when I create with these its not triggering. below is the formula I'm using. Its working when edited the record.
AND(
 OR(
    AND(NOT(ISBLANK([Address__c].Street__c)),ISCHANGED([Address__c].Street__c)), 
    AND(NOT(ISBLANK([Address__c].State__c)),ISCHANGED([Address__c].State__c)), 
    AND(NOT(ISBLANK([Address__c].City__c)),ISCHANGED([Address__c].City__c)), 
    AND(NOT(ISBLANK([Address__c].ZipCode__c)),ISCHANGED([Address__c].ZipCode__c)), 
    AND(NOT(ISBLANK([Address__c].Country__c))ISCHANGED([Address__c].Country__c))
   )
)




 
Hi,
Is there any sample code for Image upload, Rotate, and Crop using JQuery or any other tools? after that I want to save the image in Attachment. 

Thanks
Hi,
We have a process uploading image through VF which inclued cropping image as well, but some photos after uploaded they are rotated to horizontal and we don't have an option to rotate back. Is there a way to auto rotate to potrait? or is there a way to rotate ? please see the code below?
<apex:page controller="ImageCropper" id="pg" showHeader="false" sidebar="false" >
   <head>
      <meta http-equiv='cache-control' content='no-cache'/>
      <meta http-equiv='expires' content='0'/>
      <meta http-equiv='pragma' content='no-cache'/>      
   </head>
    
  <body>
      <style>
           .btn_active{
                height: 25px;
                padding: 0px 15px !important;
                border: 1px solid #CCC !important;
                color: #015BA7;
                font-weight: bold !important;
                font-family: arial !important;
                font-size: 12px;
                position: relative !important;
                left: 0px !important;
                cursor: pointer !important;
                border-radius: 2px !important;
                line-height: 26px !important;
                text-decoration: none !important;
                display: inline-block;
            }
      </style>
      <!--<apex:inputHidden id="DocId" value="{!DocID}"/>-->
              
      <apex:outputPanel rendered="{!NOT(doneuploading)}">
          
         <apex:form id="frm1">
             
            <apex:actionFunction name="EditProfilePicture" id="editpic" action="{!uploadPicture}">
               <apex:param value="false" name="uploadDoc" assignTo="{!uploadCroping}"/>
            </apex:actionFunction>
            <!--Start ChangeProfile_picture-->
            <div class="ChangeProfile_picture"  style="display: block; margin: 0 auto;width: 250px;">
               <center>
                  <div style="font-size: x-large;">Upload Your Photo </div>
                  
               </center>
               <!--Start formbox-->
               <div class="formbox" style="width:100% !important; margin-left:-20% !important">
                  <form>
                     <table class="table" border="0" cellpadding="5" cellspacing="0">
                        
                        <tr>
                           <td>
                              <center>
                              <label>
                                 <apex:inputFile style="padding: 4.5px 10px;width: 95.5%;" id="fileid" fileSize="{!fsize}" accept="image/jpeg" size="40" title="Browse"  value="{!propFileBody}" fileName="{!propFileName}"  contentType="{!propContentType}" ></apex:inputFile>
                              </label>                              
                              <div class="paginationstyle" style="display:inline"><a href="javascript: void(0);" class="btn_active" onclick="validateProfilePicture(); return false;" title="Submit">Crop your photo</a>
                              </div>  
                              <br/>
                             <div id="ErrorDiv" style="color: red;"> </div>
                              <apex:messages style="color: red; font-size: 10px; background-color:#ffffe0;font-weight:bold !important;"/>
                              </center>                            
                           </td>
                        </tr>
                     </table>
                  </form>
               </div>
               <!--End formbox-->    
            </div>
         </apex:form>
      </apex:outputPanel>
      <apex:outputPanel rendered="{!doneuploading}">
         <style>
            .imageBox {
                position: relative;
                height: 580px;
                width: 600px;
                border:1px solid #aaa;
                background: #fff;
                overflow: hidden;
                background-repeat: no-repeat;
                cursor:move;
            }
            .imageBox .thumbBox {
                position: absolute;
                top: 25%;
                left: 45%;
                width: 294px;
                height: 376px;
                margin-top: -50px;
                margin-left: -125px;
                box-sizing: border-box;
                border: 1px solid rgb(102, 102, 102);
                box-shadow: 0 0 0 1000px rgba(0, 0, 0, 0.5);
                background: none repeat scroll 0% 0% transparent;
            }
            .imageBox .spinner {
                position: absolute;
                top: 0;
                left: 0;
                bottom: 0;
                right: 0;
                text-align: center;
                line-height: 400px;
                background: rgba(0,0,0,0.7);
            }
            .container {
                position: relative;
                top: 10%;
                margin: 0 auto;
                width: 600px;
            }
            .action {
                width: 600px;
                height: 30px;
                margin: 10px 0;
            }
            .cropped>img {
                margin-right: 10px;
            }           
         </style>
         <apex:form id="frm2">
            <apex:actionFunction name="UploadCropPicture" id="croppic" action="{!uploadPicture}" reRender="outputcrop" oncomplete="oncompCropping();">
               <apex:param value="" name="dataurl" assignTo="{!inputdataUrl}"/>
               <apex:param value="true" name="uploadcroping" assignTo="{!uploadCroping}"/>
            </apex:actionFunction>
            <div class="container">
               <div class="imageBox">
                  <div class="thumbBox"></div>
                  <div class="spinner" style="display: none">Loading...</div>
               </div>
               <div class="action">
                  <a href="javascript:void(0);" id="btnCrop" class="btn_active" style="float: right;text-align:center;background-color: #011E41;color:white;">Crop</a>
                  <a href="javascript:void(0);" id="btnZoomIn" class="btn_active" style="float: right;text-align:center;background-color: #011E41;color:white;">Zoom IN</a>
                  <a href="javascript:void(0);" id="btnZoomOut" class="btn_active" style="float: right;text-align:center;background-color: #011E41;color:white;">Zoom Out</a>
               </div>
               <div class="cropped">
               </div>
            </div>
         </apex:form>
      </apex:outputPanel>
   </body>
   <apex:outputPanel id="outputcrop">
      <script type="text/javascript">
         'use strict';
         var cropbox = function(options){
             var el = document.querySelector(options.imageBox),
             obj = {
                 state : {},
                 ratio : 1,
                 options : options,
                 imageBox : el,
                 thumbBox : el.querySelector(options.thumbBox),
                 spinner : el.querySelector(options.spinner),
                 image : new Image(),
                 getDataURL: function () {
                     var width = this.thumbBox.clientWidth,
                         height = this.thumbBox.clientHeight,
                         canvas = document.createElement("canvas"),
                         dim = el.style.backgroundPosition.split(' '),
                         size = el.style.backgroundSize.split(' '),
                         dx = parseInt(dim[0]) - el.clientWidth/2 + width/2,
                         dy = parseInt(dim[1]) - el.clientHeight/2 + height/2,
                         dw = parseInt(size[0]),
                         dh = parseInt(size[1]),
                         sh = parseInt(this.image.height),
                         sw = parseInt(this.image.width);
         
                     canvas.width = width;
                     canvas.height = height;
                     var context = canvas.getContext("2d");
                     context.drawImage(this.image, 0, 0, sw, sh, dx, dy, dw, dh);
                     var imageData = canvas.toDataURL('image/jpeg');
                     return imageData;
                 },
                 getBlob: function() {
                     var imageData = this.getDataURL();
                     var b64 = imageData.replace('data:image/jpeg;base64,','');
                     var binary = atob(b64);
                     var array = [];
                     for (var i = 0; i < binary.length; i++) {
                         array.push(binary.charCodeAt(i));
                     }
                     return new Blob([new Uint8Array(array)], {type: 'image/jpeg'});
                 },
                 zoomIn: function () {
                     this.ratio*=1.1;
                     setBackground();
                 },
                 zoomOut: function () {
                     this.ratio*=0.9;
                     setBackground();
                 }
             },
             attachEvent = function(node, event, cb) {
                 if (node.attachEvent)
                     node.attachEvent('on'+event, cb);
                 else if (node.addEventListener)
                     node.addEventListener(event, cb);
             },
             detachEvent = function(node, event, cb) {
                 if(node.detachEvent) {
                     node.detachEvent('on'+event, cb);
                 }
                 else if(node.removeEventListener) {
                     node.removeEventListener(event, render);
                 }
             },
             stopEvent = function (e) {
                 if(window.event) e.cancelBubble = true;
                 else e.stopImmediatePropagation();
             },
             setBackground = function() {
                var elemArray = document.getElementsByClassName("imageBox")[0].style.backgroundPosition;
                if(elemArray.length == 0) {
                 var w =  parseInt(obj.image.width)*obj.ratio;
                 var h =  parseInt(obj.image.height)*obj.ratio;
                 var pw = (el.clientWidth - w) / 2;
                 var ph = (el.clientHeight - h) / 2;
                 el.setAttribute('style',
                         'background-image: url(' + obj.image.src + '); ' +
                         'background-size: ' + w +'px ' + h + 'px; ' +
                         'background-position: ' + pw + 'px ' + ph + 'px; ' +
                         'background-repeat: no-repeat');
                }
                if(elemArray.length>0) {
                 var w =  parseInt(obj.image.width)*obj.ratio;
                 var h =  parseInt(obj.image.height)*obj.ratio;
                 var pw = (el.clientWidth - w) / 2;
                 var ph = (el.clientHeight - h) / 2;
                
                 el.setAttribute('style',
                         'background-image: url(' + obj.image.src + '); ' +
                         'background-size: ' + w +'px ' + h + 'px; ' +
                         'background-position: '+elemArray+'; ' +
                         'background-repeat: no-repeat');
                }
             },
             imgMouseDown = function(e) {
                 stopEvent(e);
                 obj.state.dragable = true;
                 obj.state.mouseX = e.clientX;
                 obj.state.mouseY = e.clientY;
             },
             imgMouseMove = function(e) {
                 stopEvent(e);
                 if (obj.state.dragable) {
                     var x = e.clientX - obj.state.mouseX;
                     var y = e.clientY - obj.state.mouseY;
         
                     var bg = el.style.backgroundPosition.split(' ');
         
                     var bgX = x + parseInt(bg[0]);
                     var bgY = y + parseInt(bg[1]);
         
                     el.style.backgroundPosition = bgX +'px ' + bgY + 'px';
         
                     obj.state.mouseX = e.clientX;
                     obj.state.mouseY = e.clientY;
                 }
             },
             imgMouseUp = function(e) {
                 stopEvent(e);
                 obj.state.dragable = false;
             },
             zoomImage = function(e) {
                 var evt=window.event || e;
                 var delta=evt.detail? evt.detail*(-120) : evt.wheelDelta;
                 delta > -120 ? obj.ratio*=1.1 : obj.ratio*=0.9;
                 setBackground();
             }
         
             obj.spinner.style.display = 'block';
             obj.image.onload = function() {
                 obj.spinner.style.display = 'none';
                 setBackground();
         
                 attachEvent(el, 'mousedown', imgMouseDown);
                 attachEvent(el, 'mousemove', imgMouseMove);
                 attachEvent(document.body, 'mouseup', imgMouseUp);
                 var mousewheel = (/Firefox/i.test(navigator.userAgent))? 'DOMMouseScroll' : 'mousewheel';
                 attachEvent(el, mousewheel, zoomImage);
             };
             obj.image.src = options.imgSrc;
             attachEvent(el, 'DOMNodeRemoved', function(){detachEvent(document.body, 'DOMNodeRemoved', imgMouseUp)});
         
             return obj;
         };
      </script>
      <script type="text/javascript">
         var imageData;
         
         function validateProfilePicture(){
             var inpt_file = document.getElementById('pg:frm1:fileid');
             if(inpt_file.value == '' || inpt_file.fileName == '' || inpt_file.contentType == ''){             
                 document.getElementById('ErrorDiv').innerHTML = '<b>Error:</b> Please specify a file to upload, or use the "Browse" button to locate it in your local file system.';
             }
             else{
             document.getElementById('ErrorDiv').innerHTML = '';
             window.resizeTo(750, 700);
             EditProfilePicture(false);
             }
         }
         
         function loadcropper() {
             var options =
             {
                 imageBox: '.imageBox',
                 thumbBox: '.thumbBox',
                 spinner: '.spinner',
                 imgSrc: '{!upldocUrl}'
             }
             var cropper = new cropbox(options);
             document.querySelector('#btnCrop').addEventListener('click', function(){
                 imageData = cropper.getDataURL();

                 var r = window.confirm("Are you sure you want to upload this profile picture?");
                 if (r == true) {
                     UploadCropPicture(imageData,true);
                 } else {}                
             });
             document.querySelector('#btnZoomIn').addEventListener('click', function(){
                 cropper.zoomIn();
             });
             
             document.querySelector('#btnZoomOut').addEventListener('click', function(){
                 cropper.zoomOut();
             });
         }
         
         function onclickData()
         {
             imageData = $('.image-editor').cropit('export');
         }
         function loadImagesection(){        
             var doneuploading = {!doneuploading};
             if(doneuploading)
             {
                 loadcropper();          
             }
         }
         
         function oncompCropping() {
             var doneuploadingtemp = {!doneuploadingCroping};
             if(doneuploadingtemp) {
                 var DocId = "{!DocID}"; 
                 window.opener.updateURL(DocId);
             }
         }
         loadImagesection();
      </script>
   </apex:outputPanel>
</apex:page>

 
Hi,
I have a PUBLIC SITE (url=uploadphoto) which uploads image and stores into Attachment, but after file upload, need to display on page but not able to show.
I used the below URLs to display.
<img src="/uploadphoto/servlet/servlet.FileDownload?file={!attID}" style="height: 160px; width:200px;" />

or

<apex:image url="/uploadphoto/servlet/servlet.FileDownload?file={!attID}" style="height: 160px; width:200px;" />
If public sites will not have access to Attachment, can we call RemoteAction and get image string and show? how could we do that?

Please advice
I have a request that end user open a page and process multiple records (with check boxes) with single shot. For this I have built lightning component and made it working. I used Lightning App to test the component. Do I have to create a new App and give the link to them (https://mydomain.lightning.force.com/c/ProcessApp.app) or create a Visualforce and embed the component and give the VF link (https://../apex/ProcessPage) to them? which one is best? Please advice.

Thanks
Hi,
I have a page with three upload files, I have used JavaScript remoting to upload them to Attachment. I need to show those images on pase as soon as I stored them but not able to display, i tried the following scenarios but no use. 

1) 
var img = document.createElement("img");
img.src = "/servlet/servlet.FileDownload?file="+attachmentId;
document.getElementById('photoIcon').appendChild(img);


<div id="photoIcon" />

2:
var imageicon = "/servlet/servlet.FileDownload?file="+attachmentId;
/document.getElementById('photoIcon').src = imageicon;


<img id="photoIcon" />
3.
//document.getElementById("photoIcon").innerHTML="<img src='/servlet/servlet.FileDownload?file='"+attachmentId+" />";
document.getElementById("photoIcon").innerHTML='<img src=="{!URLFOR($Action.Attachment.Download, '00P1D000000OiF0UAK')}"/>';
But no use.. is it possible to display them after we save attachment from Remoting?
Please Advice.

Thanks

 
Hi,
I have one page that loads the images (3), and click on review button to review the images. On review page if you user want to go back and reupload only one file this time but on review page the old images are still showing. I have other fileds should keep the values but I want these image fields must reset before reupload. I was setting null in apex but no use. how can we clear them? The following is the code
VF:
<apex:pageblocksection columns="2" >
                            <apex:outputLabel value="Upload Photo: "/> 
                            <apex:outputpanel layout="block" styleClass="requiredInput" rendered="{! !isUnderReviewPhoto}">
                                <apex:outputpanel layout="block" styleClass="requiredBlock"></apex:outputpanel>
                                <apex:inputFile value="{!photoFile}" id="photoFile"/>
                            </apex:outputpanel>
                            <apex:outputpanel layout="block" styleClass="requiredInput" rendered="{!isUnderReviewPhoto}">
                            	<apex:image value="{!photoString}" height="200" width="200"/> 
                            </apex:outputpanel>
                        </apex:pageblocksection>
                        
                        <apex:pageblocksection columns="2" >
                            <apex:outputLabel value="Upload Driver's License Front: "/> 
                            <apex:inputFile value="{!licenseFrontFile}" id="licenseFrontFile" rendered="{! !isUnderReviewPhoto}"/>
                            <apex:outputpanel layout="block" rendered="{!isUnderReviewPhoto}">
                                <apex:image value="{!licenseFrontString}" height="200" width="200" rendered="{!licenseFrontString!=null}"/> 
                                <apex:outputPanel rendered="{!licenseFrontString == null}"><em>No License file uploaded</em></apex:outputPanel>
                            </apex:outputpanel>
                        </apex:pageblocksection>
                        
                        <apex:pageblocksection columns="2" >
                            <apex:outputLabel value="Upload Driver's License Back:" /> 
                            <apex:inputFile value="{!licenseBackFile}" id="licenseBackFile" rendered="{! !isUnderReviewPhoto}"/>
                        	<apex:outputpanel layout="block" rendered="{!isUnderReviewPhoto}">
                                <apex:image value="{!licenseBackString}" height="200" width="200" rendered="{!licenseBackString!=null}"/> 
                                <apex:outputPanel rendered="{!licenseBackString == null}"><em>No License file uploaded</em></apex:outputPanel>
                            </apex:outputpanel>
                        </apex:pageblocksection>

Apex class:
global Pagereference goBack() {
        system.debug(' goBack ');
        try{
            isUnderReviewPhoto=false;
            photoFile=null;
            licenseFrontFile=null;
            ApexPages.CurrentPage().getparameters().put('licenseFrontFile',null);
            licenseBackFile=null;
            photoString =null;
            licenseFrontString=null;
            licenseBackString=null;
            system.debug(' goBack reset');
        }catch (Exception e){
            system.debug(' Something happened in goBack : '+e);  
        }
        return new PageReference('/apex/GOCardPhotoUpload');
    }

 
I have custom object and it has Notes and Files related list, I want to restrict to one Note and one File for each custom record. Would that be possible?
I have a requirement that ananymous user who doesn't requre login to access a page, fills the details, saves to an object (custom, and it has lookup field  to contact) . For this I have done the below steps
  • Added Domain
  • Created new Site
  • Assigned the created VF page in to the list 'Site Visualforce Pages'
  • Activated the site
  • Gave perrmissions (RWA) to the custom object
But when I click on the page I got the following error
Authorization Required

You must first log in or register before accessing this page.
If you have forgotten your password, click Forgot Password to reset it.
We should directly access to the page without authorize, how can we do this?
Thanks,
 
Hi,

I have custom object which has a Account ( lookup ) and that account has Contact record. How can I get Contact's external Id (custom field) value ?  Please advice.

Thanks
Hi,
I have lightning components that displays images from ContentVersion as thumbnails and also links, when I click on the image its directly downloading the image but I would like it to open as preivew or open the image in a new tab/window. please advice.
below is the current line that displays image thumbnails with link to open big
<aura:iteration items="{!v.items}" var="content">
	       <a href="/sfc/servlet.shepherd/version/download/'+{!content.id}" target="_blank"> <img src="/sfc/servlet.shepherd/version/download/'+{!content.id}" width="100" height="100"/> </a>
	    </aura:iteration>

 
Hi, 
I have RestResource (httppost) that receives the data (JSON) from third party, they have bunch of members information which we need to upsert them into our system. if JSOn contains couple of records then fine but when they send 20 records then failing with "FATAL_ERROR|System.LimitException: Too many DML statements: 151". please see  below code. What is the best way to process those bunch of records? 
 
@RestResource(urlMapping='/ELPMData/*')
global with sharing class ELPMData {
	@httpPost
    global static String getMembersData(List<ELPMember> members){
        try{
            for (ELPMember elp: members){
                Bio bio = elp.bio;
                Account acc = new Account();
                acc.Name = bio.LastName+', '+bio.FirstName;
                acc.External_ID__c = bio.ID;
                acc.State__c = bio.State;
                acc.Type = 'Member';
                upsert acc External_ID__c;

                Contact con = new Contact();
                con.AccountId = acc.id;
                //Other contact fields mapping here
                upsert con External_ID__c;

                if (elp.ContactInformations != null){
                    List<Address__c> addrList = new List<Address__c>();
                    for (ContactInformation ci:elp.ContactInformations){
                        if (ci.AddressID != null && ci.AddressID != ''){
                            System.debug(' INSIDE ADDRESS '+ci.AddressID);
                            Address__c add = new Address__c();
                            add.AddressID__c = ci.AddressID;
                            //Other Address fields mapping here
                            addrList.add(add);
                        }
                    }
                    if (addrList.size()>0){
                        upsert addrList AddressID__c;
                    }
                }
                if (elp.Affiliations != null){
                    List<Affiliation__c> affilList = new List<Affiliation__c>();
                    for (Affiliation aff:elp.Affiliations){
                        if (aff.UniqueID != null && aff.UniqueID != ''){
                            Affiliation__c elpAffl = new Affiliation__c();
                            elpAffl.UniqueID__c = aff.UniqueID;
                            //Other Affiliation__c fields mapping here
                            affilList.add(elpAffl);
                        }
                        
                    }
                    if (affilList.size()>0){
                        upsert affilList UniqueID__c;
                    }
                }
                if (elp.Educations != null){
                    List<Education__c> eduList = new List<Education__c>();
                    for (Education edu:elp.Educations){
                        if (edu.InstitutionID != null && edu.InstitutionID != ''){
                            Education__c elpEdu = new Education__c();
                            elpEdu.InstitutionID__c = edu.InstitutionID;
                            //Other Education mapping here
                            eduList.add(elpEdu);
                        }
                    }
                    if (eduList.size()>0){
                        upsert eduList InstitutionID__c;
                    }
                }
                if (elp.Employments != null){
                    List<Employment__c> empList = new List<Employment__c>();
                    for (Employment emp:elp.Employments){
                        if (emp.UniqueID != null && emp.UniqueID != ''){
                            Employment__c elpEmp = new Employment__c();
                            elpEmp.UniqueID__c = emp.UniqueID;
                            //Other Employments mapping here
                            empList.add(elpEmp);
                        }
                    }
                    if (empList.size()>0){
                        upsert empList UniqueID__c;
                    }
                }
                
               
            }
        }catch(Exception e){
            System.debug('The following exception has occurred: ' + e.getMessage());
			return 'Integration FAILED, check with GU Admins';
        }
        return 'SUCCESS';
    }
    
    global class ELPMember {
        global Bio Bio {get;set;}
        global List<ContactInformation> ContactInformations {get;set;}
        global List<Affiliation> Affiliations {get;set;}
        global List<Education> Educations {get;set;}
        global List<Employment> Employments {get;set;}
    }
    global class Bio{
        //All Bio fields
    }
    global class Education {
        //All Education Fields
    }
    global class Affiliation{
        //All Affiliation fields
    }
    global class ContactInformation{
        //All Contact Fields
    }
    
    global class Employment{
        //All Employment fields
    }
    
}


 they may have 10000 members which we need to insert first time. 
Hi,
I have a process builder which calls Apex method (@InvocableMethod) and the apex method calls future callout, this process is failing with the below error. I have the code checking !system.isFuture() but still failing, not able to figure out.
Error element myRule_1_A1 (FlowActionCall).
An Apex error occurred: System.AsyncException: Future method cannot be called from a future or batch method: AddressValidateController.invokeAddressController(List)
Apex Code is below.
global with sharing class AddressValidateController {
    public static boolean isVerified = false;
   
	@InvocableMethod
    global static void validateAddressFromPB(List<Id> recIds){
       
        if(!system.isFuture() && !isVerified){
            integer count = 0;
            List<String> subList = new List<String>();
            for (Id recId:recIds){
                count+=1;
                subList.add(recId);
                if (Math.Mod(count, 100)==0){
                    invokeAddressController(subList);
                    subList=new List<String>();
                }
            }
            invokeAddressController(subList);
            isVerified = true;
        }
    }
    
    
	@future(callout=true)
    global static void invokeAddressController(List<Id> recIds){
        
               Address validation callout code here
    }
}

Please advice..!
 
I have created an external field in Account and have very simple code that upserts Account record.
below is the code
Account a = new Account();
a.name='Testing 99test9911';
a.Account_External_Id__c='99test99';
upsert a;
First time it creatd record but next time when I ran it failed (below is error), my environment is pretty much new (no triggers and no Workflows and no ProcessBuilders), I don't know how to fix this. Please advice
12:11:45:057 EXCEPTION_THROWN [4]|System.DmlException: Upsert failed. First exception on row 0; first error: DUPLICATE_VALUE, duplicate value found: Account_External_Id__c duplicates value on record with id: 0010t0000137DHM: []

 
HI,
I need to pull the all ContentDocumentLink recrods related to All Contacts (30K) and update LinkedEntityId (related to Contact) with new custom object record ids. while updating ContentDocumentLink record  I got below error
LinkedEntityIdUnable to create/update fields: LinkedEntityId. Please check the security settings of this field and verify that it is read/write for your profile or permission set.INVALID_FIELD_FOR_INSERT_UPDATEfalse
I'm using python script to do this (but apex solution is also fine). please check below code
query_result  = self.svc.query("select id from contact where Student__c=true and id='00336000014TJv9'")
            cnt=0
            contList=[]
            while True:
                for row in query_result[self.sf.records:]:
                    cnt+=1
                    contList.append(str(row[1]))
                if str(query_result[self.sf.done]) == 'true':
                    break
                query_result = self.svc.queryMore(str(query_result[self.sf.queryLocator]))
            for con in contList:
                links = self.svc.query("select id,ContentDocumentid from ContentDocumentLink where LinkedEntityId = '"+str(con)+"' limit 1");
                if (links!=None and len(links)>0):
                    for link in links[self.sf.records:]:
                        writer.writerow({'Contac_ID': str(con), 'Document_ID': str(link[3]),'Document_Linked_ID': str(link[1])})
                        emNotes = {
                            'type' : 'Em_Note__c',
                            'Contact__c' : str(con),
                            'Name' : str(link[3])
                        }
                        results = self.svc.create(emNotes )
                        emNotesID= results[0]
                        contentDocumentLink = {
                            'type' : 'ContentDocumentLink',
                            'id' : str(link[1]),
                            'LinkedEntityId' : str(emNotesID)
                        }
                        self.svc.update(contentDocumentLink); # I guess the error is here
Please advice


 
Hi,
I have below SOQL clause with Static Year and Month, is it possible to have dynamic values in those fields?
(
  ( 
     ( YEAR__c=2016 and Month__c='July' )  or 
     ( YEAR__c=2016 and Month__c='August' ) or 
     ( YEAR__c=2016 and Month__c='September' ) or 
     ( YEAR__c=2016 and Month__c='October' ) or 
     ( YEAR__c=2016 and Month__c='November' ) or  
     ( YEAR__c=2016 and Month__c='December' ) or 
     ( YEAR__c=2017 and Month__c='January' ) or 
     ( YEAR__c=2017 and Month__c='February' ) or 
     ( YEAR__c=2017 and Month__c='March' ) or 
     ( YEAR__c=2017 and Month__c='April' ) or 
     ( YEAR__c=2017 and Month__c='May' ) or 
     ( YEAR__c=2017 and Month__c='June' )
  ) 
  OR YEAR__c=null
)
)

 
I have BioRecord custom object which has Email, Phone, Status(picklist, Current, Former), Type (picklist, Home, Office, etc) and Record type (Phone and Email), we have integration that writes the data into this object. If a record is existed with a Type='Home' and recordtype='Phone' and if a new record comes with the same Type and same recordtype, I need to change the status of old record to 'Former'. 
i'm guessting that I can do it in Trigger but is there any alternate way we can change the Status of the record? 
I have a custom Address object, which has address fields, phone, and email fields. I'm wriging Process Builder on this object, with the following steps
1) Start the process, when a record created or edited
2) criteria.:
      Criteria for Executing Actions: Formula Evaluates to True
The formula should be on fields (Street, City , state, zipcode), one of these created, edited only the Process should trigger but when I create with these its not triggering. below is the formula I'm using. Its working when edited the record.
AND(
 OR(
    AND(NOT(ISBLANK([Address__c].Street__c)),ISCHANGED([Address__c].Street__c)), 
    AND(NOT(ISBLANK([Address__c].State__c)),ISCHANGED([Address__c].State__c)), 
    AND(NOT(ISBLANK([Address__c].City__c)),ISCHANGED([Address__c].City__c)), 
    AND(NOT(ISBLANK([Address__c].ZipCode__c)),ISCHANGED([Address__c].ZipCode__c)), 
    AND(NOT(ISBLANK([Address__c].Country__c))ISCHANGED([Address__c].Country__c))
   )
)




 
Hi,
I have a PUBLIC SITE (url=uploadphoto) which uploads image and stores into Attachment, but after file upload, need to display on page but not able to show.
I used the below URLs to display.
<img src="/uploadphoto/servlet/servlet.FileDownload?file={!attID}" style="height: 160px; width:200px;" />

or

<apex:image url="/uploadphoto/servlet/servlet.FileDownload?file={!attID}" style="height: 160px; width:200px;" />
If public sites will not have access to Attachment, can we call RemoteAction and get image string and show? how could we do that?

Please advice
I have a request that end user open a page and process multiple records (with check boxes) with single shot. For this I have built lightning component and made it working. I used Lightning App to test the component. Do I have to create a new App and give the link to them (https://mydomain.lightning.force.com/c/ProcessApp.app) or create a Visualforce and embed the component and give the VF link (https://../apex/ProcessPage) to them? which one is best? Please advice.

Thanks
I have a requirement that ananymous user who doesn't requre login to access a page, fills the details, saves to an object (custom, and it has lookup field  to contact) . For this I have done the below steps
  • Added Domain
  • Created new Site
  • Assigned the created VF page in to the list 'Site Visualforce Pages'
  • Activated the site
  • Gave perrmissions (RWA) to the custom object
But when I click on the page I got the following error
Authorization Required

You must first log in or register before accessing this page.
If you have forgotten your password, click Forgot Password to reset it.
We should directly access to the page without authorize, how can we do this?
Thanks,
 
Hi,
I can get the Object name with the following code but how can I get this objName using SOQL?
String objName = recId.getSObjectType().getDescribe().getName()
I'm using java/python code to call SOQLs for some other work (integration) I need to know the object names by record ids in Java/Python. Please advice
 
How can I get parent's parent record fields from a child query? Is it possible? like join in SQL
The following is relationship with objects
Book__c  has lookup field Shop__c
Shop__c has lookup field Account
Account has a externalID

I want to get Account's externalID with the Book__c ID.

to Continue my question, in SQL I'll use to get parent's parent record field with this
select acc.relID 
from BOA b​oa, Contact con, Account acc 
where acc.accID = con.accID 
and con.conID = boa.conID 
and boa.boaID='ABC12342323'
Please advice
 
Hi,
I know Salesforce has limitations but I would need alternate to this issue, please check the below code and provide alternate to that?
The requirement is: calling externam API that has 28000 records to get and that API has limitations on results (only 400 allows) so loooping 72 to get 28K and another for loop on 400 records.

@future (callout=true)
    public static void getAllUsersFromCampusLabs(){
        for (integer i=1;i<=72;i++){
            Map<String,String> parameters = new Map<String,String>();
            parameters.put('page',string.valueof(i));
            parameters.put('page','1');
            parameters.put('pageSize','400');
            String respString = DataAccessController.call_RESTFulAPI_Request('users',parameters);
            Map<String, Object> jsonMap = (Map<String, Object>) JSON.deserializeUntyped(respString);
            List<Object> usersList = (List<Object>)jsonMap.get('items');
                for (Object userObject:usersList){
                    Map<String, Object> user = (Map<String, Object>)userObject;
                    String jsonUserName = String.valueOf(user.get('userId')).trim();
                    String userName = (String)user.get('username');
                    String netID = userName.split('@')[0].trim().toLowerCase();
                    List<Contact> userContacts = [SELECT ID,userID__c,userName__c  from Contact where userID__c=:netID];
                    if (userContacts.size()>0){
                        Contact userContact = userContacts[0];
                        userContact.userName__c = jsonUserName;
                         update userContact;
                    }
                }
            }
    }
Hi,

How can I generate Digital Signature with the following Strings I have? 
Note: The cryptographic hash functions are supported: MD5, SHA-256, SHA-384, and SHA-512

The Strings are : 
 apikey
 ipaddress
 utctime
 randomguid
 privatekey

I need to genrate just like the following 
$hash = encrypt($apikey + $ipaddress + $time + $random + $privatekey);

Please advice.
Hi, 
I have a Custom object (Transaction) which has Lookup(Account) field and in Contact object I have a custom field (ABC_internal_id). I need to access ABC_internal_id field with the SOQL query on Transaction object (by transaction ID). It might be a simple question but please let me get the clue.