• Dushyant Sonwar
  • PRO
  • 3850 Points
  • Member since 2014
  • Senior Salesforce Developer


  • Chatter
    Feed
  • 85
    Best Answers
  • 0
    Likes Received
  • 2
    Likes Given
  • 1
    Questions
  • 650
    Replies
display get response data in vf page, json response please help 

VF page :

<apex:page controller="RESTAPIJSONResponseController">
    <apex:form >
        <apex:pageBlock >            
            <apex:pageBlockButtons location="bottom">
                <apex:commandButton value="Fetch" action="{!fetchAPI}"/>
            </apex:pageBlockButtons>
        </apex:pageBlock>
        
        <apex:pageblock >
            <apex:pageBlockSection >
                <apex:pageBlockTable value="{!listWrapper}" var="obj">
                    <apex:column value="{!obj.rates}" headerValue="Id"/>
                    <apex:column value="{!obj.base}" headerValue="Login"/>
                    

 

                    
                </apex:pageBlockTable>
            </apex:pageBlockSection>
        </apex:pageblock>
    </apex:form>
</apex:page>

Controller: 
public with sharing class RESTAPIJSONResponseController {

    public List < JSONWrapper > listWrapper {get;set;}
    
    public RESTAPIJSONResponseController() {
        listWrapper = new List < JSONWrapper >();
    }
    
    public void fetchAPI() {
        HTTP h = new HTTP();
        HTTPRequest req = new HTTPRequest();
        req.setEndPoint('https://theforexapi.com/api/latest?HTTP/2');
        req.setMethod('GET');
        HTTPResponse res = h.send(req);  
        JSONParser parser = JSON.createParser(res.getBody());
        listWrapper = (List < JSONWrapper >) JSON.deSerialize(res.getBody(), List < JSONWrapper >.class);
        system.debug(''+res.getBody() );
        /*
           If the response contains only one value instead list, then you can use the below code
           JSONWrapper obj = (JSONWrapper) JSON.deSerialize(res.getBody(), JSONWrapper.class); 
           listWrapper.add(obj);
        */
    }
    
    public class JSONWrapper {
        
        public String base {get;set;}
        public String rates {get;set;}
        
    }
    
}

JSON Response :  in system.debug
"{\"date\":\"2021-07-07\",\"base\":\"EUR\",\"rates\":{\"USD\":\"1.1831\",\"JPY\":\"130.86\",\"BGN\":\"1.9558\",\"CZK\":\"25.688\",\"DKK\":\"7.4361\",\"GBP\":\"0.85500\",\"HUF\":\"355.57\",\"PLN\":\"4.5192\",\"RON\":\"4.9268\",\"SEK\":\"10.1813\",\"CHF\":\"1.0917\",\"ISK\":\"146.30\",\"NOK\":\"10.2475\",\"HRK\":\"7.4867\",\"RUB\":\"87.8009\",\"TRY\":\"10.2566\",\"AUD\":\"1.5711\",\"BRL\":\"6.1224\",\"CAD\":\"1.4708\",\"CNY\":\"7.6478\",\"HKD\":\"9.1900\",\"IDR\":\"17146.47\",\"INR\":\"88.2825\",\"KRW\":\"1344.89\",\"MXN\":\"23.5724\",\"MYR\":\"4.9241\",\"NZD\":\"1.6760\",\"PHP\":\"58.960\",\"SGD\":\"1.5924\",\"THB\":\"38.173\",\"ZAR\":\"16.8666\"}}"

Visualforce Error:
System.JSONException: Malformed JSON: Expected '[' at the beginning of List/Set
Error is in expression '{!fetchAPI}' in component <apex:commandButton> in page forexconv: Class.System.JSON.deserialize: line 15, column 1
Class.RESTAPIJSONResponseController.fetchAPI: line 16, column 1

Need to display This format :
Need to display this format
To This  Type : 
User-added image

Please Help With this Issue,
Thanks in Advance.




 
I'm creating a simple VFP to render as PDF and I would like to get some picklist fields. The problem is that I'm getting the API Name and not the label value. There's a way to do it using only VFP?

Example of how I'm doing:
Status: <br/>{!CPRMinutes__c.Status__c}
User-added imageHi Team,

I want to display error mesg when we select 'Other-Explain'.
<apex:page showHeader="false" action="{!InitMethod}" cache="false" controller="AH_HN_PhysicianAcceptnReject_CLS" tabStyle="Case">
    <apex:includeScript value="/soap/ajax/36.0/connection.js"/>
    <apex:includeScript value="/soap/ajax/36.0/apex.js"/>
    <apex:includeLightning />
    <apex:Pagemessages />
    
    <head>
        <apex:slds />
        <div class="slds-align_absolute-center">
            <apex:image url="{!$Resource.AH_Physician_Expert_Template_Logo}" />
        </div>
    </head>
    
    <apex:form >
        <div class="slds-align_absolute-center">
            
            <apex:outputText rendered="{!ThanksmsgAccpt}">
                <span style="font-size:20px;font-weight:bold;" class="slds-m-top_xx-large">Thank you for accepting, the case has now been added to your dashboard.  Please log into the physician portal to begin your review.</span>
            </apex:outputText> 
            
            <!--
<apex:outputText rendered="{!ThanksmsgRejec}">
<span style="font-size:20px;font-weight:bold;" class="slds-m-top_xx-large">Thank you for rejecting the case.<br/> </span>
</apex:outputText>
-->
            
            
            <apex:outputText rendered="true">
                <apex:pageBlock >
                    <!-- span style="font-size:20px;font-weight:bold;" class="slds-m-top_xx-large">Thank you for rejecting the case.<br/><br/> </span -->
                    
                    <p>Please select the reason:</p>
                    <apex:actionRegion >
                    <apex:selectList id="Pleaseselectthereason" size="1" label="caseRejectReason"  value="{!caseRejectReason}">
                        <apex:selectoption itemLabel="Out of office-cannot complete due to existing workload" itemValue="Out of office-cannot complete due to existing workload"></apex:selectoption>
                        <apex:selectoption itemLabel="I recommend another physician more suitable for this case.Enter Name in Free Text Box" itemValue="I recommend another physician more suitable for this case.Enter Name in Free Text Box"></apex:selectoption>
                        <apex:selectoption itemLabel="Other - explain" itemValue="Other - explain"></apex:selectoption>
                        <!--<apex:actionSupport event="onchange" reRender="comments" />-->
                    </apex:selectList>
                    </apex:actionRegion>
    
                    <br/>
                    
                    <p>Comments:</p>
                    <apex:inputTextarea label="Comments" style="width:550px;height:100px" id="comments" value="{!caseRejectComment}"/> 
                    
                    <br/><br/>
                    
                    <div align="center" draggable="false" >
                        <apex:commandButton action="{!saveRejectInfo}" value="Save"/>
                    </div>
                    
                </apex:pageBlock>
            </apex:outputText>
            
            <apex:outputText rendered="{!rejectreasonmessage}">
                <span style="font-size:20px;font-weight:bold;" class="slds-m-top_xx-large">Thank you for rejecting the case.</span>
            </apex:outputText>
            
            
            
            
            <apex:outputText rendered="{!Assignedtoothers}">
                <span style="font-size:20px;font-weight:bold;" class="slds-m-top_xx-large">This case has already been assigned to some other physician.</span>
            </apex:outputText>
            <apex:outputText rendered="{!AlreadyAccepted}">
                <span style="font-size:20px;font-weight:bold;" class="slds-m-top_xx-large">You have already accepted the case.</span>
            </apex:outputText>
            <apex:outputText rendered="{!AlreadyRejected}">
                <span style="font-size:20px;font-weight:bold;" class="slds-m-top_xx-large">You have already rejected the case.</span>
            </apex:outputText>
        </div>   
        
        
    </apex:form>
</apex:page>
                                        
Regards,
Isha
global with sharing class products {
    @AuraEnabled
    public static List<PricebookEntry> getproduct() {

   List<PricebookEntry> prod= [SELECT Product2.Name, Unitprice FROM PricebookEntry];
  return prod;

    }
}

component--
<aura:component controller="products" > 
<aura:attribute name="productname" type="PricebookEntry[]"/>
<aura:attribute name="cols" type="List"/>  
     
    <aura:handler name="init" value="{!this}" action="{!c.doinit}"/>
   
    <lightning:datatable
            data="{!v.productname}"
            columns="{!v.cols}"
            keyField="Id"
            onrowaction="{!c.onRowAction}"/>
   
       
</aura:component>

controller---
({
	doinit : function(component) {
       component.set( 'v.cols' , [
            {
                'label': 'Name',
                'fieldName': 'Name',
                'type': 'text'
            },
{label': 'Price',
                'fieldName': 'Price',
                'type': 'Currency'
},
            {
                'label': 'Action',
                'type': 'button',
                'typeAttributes': {
                    'label': 'Add to Cart',
                    'name': 'view_details'
                }
            },
            {
                'label': 'Action',
                'type': 'button',
                'typeAttributes': {
                    'label': 'Buy',
                    'name': 'view_details'
                }
            }
            ]);
        
  var action = component.get("c.getproduct"); 
        // var self = this;
        action.setCallback(this, function(actionResult) {
            var state = actionResult.getState();
        if (state === "SUCCESS") {
          component.set("v.productname", actionResult.getReturnValue());
            component.set("v.productprice",actionResult.getReturnValue());
        }
            });
          $A.enqueueAction(action);
    },
		
	
})

Name and price of the products is not showing in datatable, but soql is executing successfully. What to do?
<div class="col-md-7">
    <apex:inputSecret value="{!newPassword}" styleClass="form-control newPass formControl" />
</div>
<!--New Addition-->
<div class="panel conditionPanel" rendered="{!ISBLANK(newPassword)}">
    <ul class="list-unstyled font-12">
        <h5 class="font-12"><span class="glyphicon glyphicon-info-sign" /><strong>{!$Label.passwordmanage}</strong> </h5>
    </ul>
</div>

I wanted show next div only when user type something in new password
I have a command button that creates a record and when it is saving it freezes for a few seconds whilst it is executing. I cannot figure a way to display that it is saving so people dont just reclicking the button. Ive seen people display a gif whilst saving but im unable to find a way to replicate this function or even display in text that it is saving
 
<apex:form style="margin: 10px; color:#322c4f">
                                    <span style="font-size:1.25em">Request callback</span>    
                                    <table style="color:#322c4f">
                                    <tr>
                                        <td colspan="2" style="color:#322c4f">
                                            User:
                                        </td>
                                        <td style="color:#322c4f">
                                            {!$User.FirstName} {!$User.LastName}
                                        </td>
                                    </tr>
                                    <tr>
                                        <td colspan="2" style="color:#322c4f">
                                            Date &#038; Time: 
                                        </td>
                                        <td style="color:#322c4f">
                                            <apex:outputText value="{0,date,dd/MM/yyyy HH:mm}"><apex:param value="{!NOW()}" /></apex:outputText>
                                        </td>
                                    </tr>
                                    <tr>
                                    </tr>
                                    <tr>
                                    <td colspan="2" style="color:#322c4f">
                                    Interested In:
                                    </td>
                                    <td style="color:#322c4f">
                                    DashCams
                                    </td>
                                    </tr>
                                    </table>
                                    <br/>
                                     <span style="padding-left: 1px">Contact:
                                    <apex:selectList multiselect="false" value="{!selectedContact}" size="1">
                                    <apex:selectOptions value="{!contacts}">
                                    </apex:selectOptions>
                                    </apex:selectList><br/>
                                
                                    Notes:<br/>
                                    <apex:inputTextarea value="{!Notes}" rows="3" style="width:50%; border: 1px solid #322c4f; color: #322c4f; margin-left:2px" /></span>
                                    <apex:commandButton styleClass="logger" value="Save" action="{!save}" style="width:25%;float: right; margin-top:40px;border: 1px solid #322c4f; color:white; padding: 10px 5px"/>
                                </apex:form>

 
Hi guys,
Been working on this for a while but unable to fugure out. 
i want to render the table only based on the click of the buttons i.e,
if i click the open cases the table should  filter and load all the open cases and 
if i click the closed cases the table should filter and load all the closed cases and like that.
but iam not able to comprehend this. 
can anyone please help me figure this out.
User-added image

---------------------------------apex controller----------------------------
public class portalCases {
    @AuraEnabled
    public static list <Case> fetchCase() {
        Return [SELECT CaseNumber,Category__c,Case_Sub_Category__c,Subject,CreatedDate FROM Case];
        
    }
}
----------------------------------component------------------------------
<aura:component controller="portalCases" implements="force:appHostable,force:hasRecordId,forceCommunity:availableForAllPageTypes" access="global">
        
    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>  
    
    <aura:attribute name="lstAllCase" type="Case[]"/>
    
    <div class="slds-m-around_xx-large, slds-align_absolute-center" id="myDIV">
        &nbsp;&nbsp;&nbsp;&nbsp;
        <button class="btn active" onclick="{!c.myAction}">Open Cases</button>&nbsp;&nbsp;&nbsp;&nbsp;
        <button class="btn" onclick="{!c.myAction}">Closed Cases</button>&nbsp;&nbsp;&nbsp;&nbsp;
        <button class="btn" onclick="{!c.myAction}">All Cases</button>&nbsp;&nbsp;&nbsp;&nbsp;
    </div>
    
    <div class="slds-m-around_medium">
        <table id="tableId" class="slds-table slds-table_bordered slds-table_cell-buffer" cellspacing="0" width="100%" >
            <thead>
                <tr>
                    <th>Case Number</th>
                    <th>Category</th>
                    <th>Sub Category</th>
                    <th>Subject</th>
                    <th>Created Date</th> 
                </tr>
            </thead>
            <tbody>
                <aura:iteration items="{!v.lstAllCase}" var="cas">
                    <tr>
                        <td>{!cas.CaseNumber}</td>
                        <td>{!cas.Category__c}</td>
                        <td>{!cas.Case_Sub_Category__c}</td>
                        <td>{!cas.Subject}</td>
                        <td>{!cas.CreatedDate}</td>
                    </tr>
                </aura:iteration>  
            </tbody>
        </table>
    </div>
    
</aura:component>

----------------------------------JScontroller-------------------------------------
({    
    doInit : function(component,event,helper){
        //call apex class method
        var action = component.get('c.fetchCase');
        action.setCallback(this, function(response) {
            //store state of response
            var state = response.getState();
            if (state === "SUCCESS") {
                component.set('v.lstAllCase', response.getReturnValue());          
            }
        });
        $A.enqueueAction(action); 
    },
    
    myAction : function(component, event, helper) {
        // Get the container element
        var btnContainer = document.getElementById("myDIV");
        
        // Get all buttons with class="btn" inside the container
        var btns = btnContainer.getElementsByClassName("btn");
        
        // Loop through the buttons and add the active class to the current/clicked button
        for (var i = 0; i < btns.length; i++) {
            btns[i].addEventListener("click", function() {
                var current = document.getElementsByClassName("active");
                current[0].className = current[0].className.replace(" active", "");
                this.className += " active";
            });
        }
    },
})
----------------------------CSS---------------------------
.THIS {
}

.THIS .btn {
    border: none;
    outline: none;
    padding: 10px 16px;
    border-radius: 8px;
    background-color: #f1f1f1;
    cursor: pointer;
}

/* Style the active class (and buttons on mouse-over) */
.THIS .active, .THIS .btn:hover {
    background-color: #1f0663;
    color: white;
}
  • March 02, 2021
  • Like
  • 0
Dear Pals,

I need to  Fire ShowNavigateToList After ShowToast On Single Save Function Of JS file,somehow only ShowToast working and not the ShowNavigateToList,Here is  what i have written for Save button,basically after the record is Upserted i want the page to move to ListView,what change is needed below
 
onConfirm:function(component, event, helper){
        var picklist=component.find('ddLevel1');
        var picklistvalue=picklist.get('v.value');
        var picklistdep=component.find('ddLevel2');
        var picklistvaluedep2=picklistdep.get('v.value');
        var picklistoldL1=component.get('v.oldL1');
        var picklistoldL2=component.get('v.oldL2');
        var picklistoldL3=component.get('v.oldL3');
        var ertrecordGuid=component.get('v.ertGUID');
        var picklistdep3=component.find('ddLevel3');
        var picklistvaluedep3=picklistdep3.get('v.value');
        var action = component.get("c.savecasetype");
       
        action.setParams({  'level1' : picklistvalue,
                          'level2' : component.get('v.secondlevelselected'),
                          'level3' : picklistvaluedep3,
                          'oldlevel1' : picklistoldL1,
                          'oldlevel2' : picklistoldL2,
                          'oldlevel3' : picklistoldL3,
                          'guid':ertrecordGuid,
                          'id' : component.get("v.recordId")});
        
        
        var toastEvent = $A.get("e.force:showToast");
        action.setCallback(this, function(e) {
            if(e.getState()=='SUCCESS'){
                var result=e.getReturnValue();
                        
                
                if(result==='successfull'){
                    toastEvent.setParams({
                        "title": "Success!",
                        "message": "The record has been Upserted  successfully."
                         
                    });
                    
                    toastEvent.fire();
                   
                }else{
                   
                    toastEvent.setParams({
                        "title": "Error",
                        "message": "The record has not been Upserted  successfully."
                    });
                    toastEvent.fire();
                }
            }
            
            
          
             $A.get('e.force:refreshView').fire(); 
             
        });
        
           var action = component.get("c.getListViews");
    action.setCallback(this, function(response){
        var state = response.getState();
        if (state === "SUCCESS") {
            var listviews = response.getReturnValue();
            var navEvent = $A.get("e.force:navigateToList");
            navEvent.setParams({
                "listViewId": listviews.Id,
                "listViewName": null,
                "scope": "Case"
            });
            navEvent.fire();
        }
    });
        $A.enqueueAction(action);
        
          
        
    }

Here is ListView controller
 
@AuraEnabled 

public static List<ListView> getListViews() { 

    List<ListView> listviews = 

        [SELECT Id, Name FROM ListView WHERE SobjectType = 'Case' and Name='Recently Viewed Cases']; 

  

   

    return listviews; 

}



Your help is needed and appreciated
Regards,
Fiona​​​​​​​

 
Hi Everyone, 

I'm working on a pdf export for Opportunities using a Visualforce page. I am able to grab all the data I need but I can't figure out how to display my lookup data fields properly in the export. 

Here is the instance of the lookup field being used:
User-added image

It is pulling data from Contacts:
User-added image

and in the export it displays as the ID and not the name:
User-added image
I have tried using ".name" in my code: <apex:outputText value="{!Opportunity.Designer_Name__c.Name}"/>

but I get this error: Error: Unknown property 'String.Name'

Any help would be greatly appreciated, thank you!
Hello,

I created a visual force page (and a custom button) which updates the account ownership from a list view. I would like to add inline editing to the below. Could you please assist me?

<apex:page standardController="Account" recordSetVar="accounts" tabStyle="Account" sidebar="false" lightningStylesheets="true">
    <apex:form >
        <apex:pageBlock title="Edit Accounts" mode="edit">
            <apex:pageMessages />
            <apex:pageblockButtons location="top">
                <apex:commandButton value="Save" action="{!Save}" />
                <apex:commandButton value="Cancel" action="{!cancel}"/>
            </apex:pageBlockButtons>
        <apex:pageBlockTable value="{!selected}" var="A">
            <apex:column headerValue="Name">
                <apex:outputField value="{!A.name}"/>
            </apex:column> 
            <apex:column headerValue="Owner">
                <apex:inputField value="{!A.OwnerId}"/>
            </apex:column>
       </apex:pageBlockTable>         
    </apex:pageBlock>
  </apex:form>
</apex:page>
I am using apex:chart tag on visualforce page, to display a chart to community users having a "Customer Community Login" license.

I've added the VF component on builder, enabled the respective VF page and controller class. But when I publish the changes, those changes don't reflect on the community for users.

What is the problem here? How should I resolve it?
 
Hi and appreciate any insight on this.

My save button no longer works.  It was a VS button.  I made a new List View button calling VFP/ APEX  Not sure what went wrong here.  

Button
 
User-added image

VFP.
<apex:page standardController="Case" recordSetVar="cases" lightningStylesheets="true" extensions="setQuickCaseExtensionController"> 
    <apex:form >
        <apex:pageBlock title="Quick Case Entry" mode="edit">
            <apex:pageMessages id="showmsg"></apex:pageMessages>
            
            <apex:pageBlockSection title="Case Details" columns="1">                 
                                
              <apex:inputField label="Source Type" required="true" value="{!case.Source_Type__c}" /> 
              <apex:inputField label="Origin" required="true" value="{!case.Origin}"/>  
              <apex:inputField label="Contact" value="{!case.ContactId}"/> 
              <apex:inputField label="Subject" required="true" value="{!case.Subject}"/> 
              <apex:inputTextArea style="width:300px;height:100px" required="true" label="Description (Min 10 chars)"  value="{!case.Description}"/>
              <apex:inputField label="Category" required="true" value="{!case.Category__c}"/> 
              <apex:inputField label="Sub-Catagory 1" required="true" value="{!case.Sub_Catagory_1__c}"/>  
              <apex:inputField label="Sub-Catagory 2" required="true" value="{!case.Sub_Category_2__c}"/>  
              <apex:inputField label="Sub-Catagory 3" required="true" value="{!case.Sub_Category_3__c}"/>              
              <apex:inputField value="{!case.Related_Account__c}" label="Account"/>          
              <apex:inputField value="{!case.Incident_Occurence_Date__c}" label="Incident Occurrence Date"/>
              <apex:inputField value="{!case.Incident_Occurrence_Time__c}" label="Incident Occurrence Time"/>  
             </apex:pageBlockSection>   
            
            <apex:pageBlockButtons > 
                <apex:commandButton value="Save & Close Quick Case" action="{!save}"/> 
                <apex:commandButton value="Cancel" action="{!cancel}"/> 
            </apex:pageBlockButtons> 
                       
          
        </apex:pageBlock> 
    </apex:form>
</apex:page>

APEX Class

public class setQuickCaseExtensionController {
   private Case QC; 
   public ApexPages.StandardSetController stdController; 
   public setQuickCaseExtensionController(ApexPages.StandardSetController controller){
        controller.setPageSize(10);
        this.QC = (Case)controller.getRecord(); 
        RecordType RecId = new RecordType();
        RecId=[SELECT Id FROM RecordType where Name='Customer First' LIMIT 1];
        QC.RecordTypeId=RecId.Id;
        QC.Quick_Case__c = True;
        QC.Origin = 'Phone';
        QC.Source_Type__c = 'Consumer';
        QC.Description='Quick Case';
        QC.Quick_Case_Closed__c = True;
        QC.Subject='New Quick Case';
        stdcontroller=controller;        
    }

}
I have a visualforce page where a user inputs serial numbers for an asset (New_Asset_Install_LOC_Serial_Number__c), I need this serial number input field to update the main serial number field on the asset Object (SerialNumber). Currently the New_Asset_Install_LOC_Serial_Number__c field is being updated on the asset, but I also need this value to populate the SerialNumber field on the asset.

Here is my visualforce code:
<apex:page docType="html-5.0" standardController="Case" extensions="installTicketUpdateAssetClass" id="thePage"> 
   
    
    <style>
    .installSerialNumber{
        }
    .setupSerialNumber {
        }
    .setupModel {
        }
    .setupModelForId {
        }
    .verify{
        }
    .update{
        }
    .autoSerialCheck{
        }
    .idNumber{
        }
    .ipAddress{
        }
    .locationRemarks{
        }
    .installNotes{
        }
    .serialDoesntMatch{
        }
    .serialDoesntMatchCheckBoxOnAsset{
        }
   
    </style>
    <p></p>


    <apex:form id="theForm"> 
        <apex:pageblock id="Assets">

            <apex:pageBlockSection id="pbs" columns="1"> <!-- to allow the apex:input to show the label -->
                
                <apex:pageBlockTable rows="1" id="pbt3" value="{!Case.Assets__r}" var="asset">
                
                    <apex:column style="width:12%;" headerValue="Product Code"><!-- to take the label dynamically -->
                         <apex:inputText style="width:80%;" disabled="true" styleClass="setupModelForId" value="{!asset.Product_Code_for_Paperless_Install_Docs__c}"  />
                    </apex:column>
                    
            		<apex:column style="width:11%;" headerValue="ID Number"><!-- to take the label dynamically -->
                        <apex:inputText required="true" style="width:80%;" styleClass="idNumber" value="{!asset.New_Asset_Install_LOC_ID_Number__c}"  />
                    </apex:column>
                    
                    <apex:column style="width:10%;" headerValue="B/W Starting Meter"><!-- to take the label dynamically -->
                        <apex:inputText required="true" styleClass="bwMeter" style="width:80%;" value="{!asset.New_Asset_Install_B_W_Meter__c}"  />
                    </apex:column>
                
               		<apex:column style="width:10%;" headerValue="Color Starting Meter"><!-- to take the label dynamically -->
                        <apex:inputText styleClass="colorMeter" style="width:80%;" value="{!asset.New_Asset_Install_Color_Meter__c}"  />
                    </apex:column>
                
                <apex:column style="width:10%;" headerValue="I.P. Address"><!-- to take the label dynamically -->
                        <apex:inputText styleClass="ipAddress" style="width:90%;" value="{!asset.New_Asset_Install_Equipment_IP_Address__c}"  />
                    </apex:column>
                    
                    <apex:column style="width:.01%;" headerValue=""><!-- to take the label dynamically -->
                        <apex:inputText disabled="true" style="width:.01%;" styleClass="setupIdNumber" value="{!asset.New_Asset_Setup_LOC_ID__c}"  />
                    </apex:column>
                
            </apex:pageBlockTable>
                
                <apex:pageBlockTable id="pbt" value="{!Case.Assets__r}" var="asset">
                                 
                    <apex:column style="width:12%;" headerValue="Product Code"><!-- to take the label dynamically -->
                         <apex:inputText style="width:80%;" disabled="true" styleClass="setupModel" value="{!asset.Product_Code_for_Paperless_Install_Docs__c}"  />
                    </apex:column>
                    
                    <apex:column style="width:12%;" headerValue="Serial Number Install"><!-- to take the label dynamically -->
                        <apex:inputText style="width:80%;" disabled="" styleClass="installSerialNumber" value="{!asset.New_Asset_Install_LOC_Serial_Number__c}"  />
                    </apex:column>
                    
                    <apex:column style="width:6%; text-align:center;" value="{!asset.Serialized__c}"/>
                    
                    <apex:column style="width:13%;" headerValue="I Verified the Serial Number"><!-- to take the label dynamically -->
                        <apex:inputCheckbox styleClass="serialDoesntMatchCheckBoxOnAsset" value="{!asset.I_Verify_the_Serial_Number_is_Correct__c}"/>
                    </apex:column>
                    
                    <apex:column style="width:.01%;" headerValue=""><!-- to take the label dynamically -->
                        <apex:inputText style="width:.01%;" disabled="true" id="pbi" styleClass="setupSerialNumber" value="{!asset.Serial_Number_Service_Setup__c}"  />
                    </apex:column>
                    
                </apex:pageBlockTable>
                </apex:pageBlockSection>
            
            
            
            <apex:pageBlockTable rows="1" id="pbt2" value="{!Case.Assets__r}" var="asset">
                
            		<apex:column style="" headerValue="Location Remarks"><!-- to take the label dynamically -->
                        <apex:inputTextarea styleClass="locationRemarks" style="width:99.45%;" value="{!asset.New_Asset_Install_Equipment_Location__c}"  />
                    </apex:column>
                    
                    <apex:column style="" headerValue="Install Notes"><!-- to take the label dynamically -->
                        <apex:inputTextarea styleClass="installNotes" style="width:99.45%;" value="{!asset.Install_Notes__c}"  />
                    </apex:column>
                
               		<apex:column headerValue="Customer DocuSign Link" >
                        <apex:outputLink target="_blank" style="width:99.45%;" value="{!case.Customer_DocuSign_Link__c}">
                            Customer DocuSign Link
                        </apex:outputLink>
                	</apex:column>
                
            </apex:pageBlockTable>
            
            <apex:pageBlockSection id="pbs2" columns="2">
                <apex:inputField id="cheaterOnSite" onchange="cheaterLeftOnSite(); return false;" value="{!case.Cheater_Left_On_Sight__c}"/>
                <apex:inputCheckbox styleClass="autoSerialCheck" onchange="" id="serialNumberVerified" disabled="" value="{!Case.Serial_Numbers_Verified__c}"/>
                <apex:inputText id="cheaterId" value="{!case.Cheater_ID__c}"/>
				<apex:inputCheckbox onchange="enableUpdateButton(); return false;" id="manualSerialNumberVerification" disabled="" value="{!Case.Manual_Serial_Number_Verification__c}"/>
                <apex:inputCheckbox id="cheaterCheckBox" value="{!case.Cheater_was_used_at_install__c}"/>
                <apex:inputCheckbox id="install" value="{!Case.Install_Complete__c}"/>
                
              
                
            </apex:pageBlockSection>
            <p class="serialDoesntMatch">
                <apex:inputCheckbox id="serialDoesntMatchCheckBox" value="{!Case.Asset.I_Verify_the_Serial_Number_is_Correct__c}"/> 
                The above serial number(s) have been verified by <strong>{!$User.FirstName} {!$User.LastName}.</strong>
                <br/>
                <strong>{!$User.FirstName} {!$User.LastName}</strong> has uploaded a document that verifies the correct serial number
               
            </p>
            <apex:pageBlockButtons location="bottom">  
                 <apex:commandButton styleClass="verify" id="verify" onclick="verifySerialNumbers(); return false;" value="Verify" />
                <apex:commandButton oncomplete="congrats(); return false;" styleClass="update" id="update" disabled="" value="Update" action="{!saveSerialIdNumber}" />
            </apex:pageBlockButtons>
        </apex:pageblock>
    </apex:form>

</apex:page>

And here is my apex class:
public class installTicketUpdateAssetClass {
    private ApexPages.StandardController controller;

    //Constructor 
    public installTicketUpdateAssetClass(ApexPages.StandardController controller) {
        this.controller = controller;
    }

    public void saveSerialIdNumber() {
        // here we use the standard controller's capability of fetching related records to update them ourselves 
        // (Casting is needed because YourChildRelationshipName__r is specific to your case object)
        update ((Case) controller.getRecord()).Assets__r;
        // here we call the standard controller's "update"
        controller.save();
    }
}

​​​​​​​Any help would be greatly appreciated

Hello, I have been a bit perplexed by this issue and could use some help.  I have a method in before update trigger that is writing the changes of a changed field ( the field name, the oldvalue, and the newvalue) of a field changed within a fieldset.  

 

The output is just the first line which is "These fields are changed and need approval: " and then nothing else prints.  Also, debugging I find that I have this in a try/catch and I am seeing the "Error:  String validation Exception on name ID" which has me very confused as well. 

 

Here is the code 

 

public static void getChangedFieldValues(Map<Id, Account> newMap, Map<Id, Account> oldMap) {

        List<Schema.FieldSetMember> approvalFields = Util.getAddressApprovalFields();

        for (Account newAcc : newMap.values()) {
            Account oldAcc = oldMap.get(newAcc.Id);

            for (FieldSetMember fsm : approvalFields ) {
                String field = fsm.getFieldPath();
                try {
                    System.debug('newAcc.get(Field) ====== ' + newAcc.get(field));
                    System.debug('oldAcc.get(Field) ====== ' + oldAcc.get(field));
                    if (newAcc.get(field) != oldAcc.get(field)) {
                        newAcc.Start_Address_Approval_Description__c = 'These address fields are changed and need approval:\n';
                        newAcc.Start_Address_Approval_Description__c += fsm.getLabel() + ' changed from: ' + oldMap.get(fsm.getFieldPath()) + ' to: ' +
                                newAcc.get(fsm.getFieldPath()) + '\n';
                    }
                } catch (Exception e) {
                    System.debug('Address Error: ' + e);
                }
            }
}


Like i said, it is updating the Description field with the first line, "These address fields are changed and need approval" , but then nothing else is getting added to the field, and at the same time I am also seeing that weird error:

Error: System.StringException: Invalid id: Name

 

Any help on why the rest is not being printed or the error would help immensely.  

Hello, all

I have added a percentage 'yearly increase' field to my Opp Product.

I am looking for a way to calculate the lifetime total of the product after x years (x being the 'term' field) if the price is increased by 'yearly increase' every year and how to track each year's price. This needs to work for any given term

for example.
  • product price = $100
  • yearly increase = 3%
  • term = 5​​​​​​​
    • year 1 price = 100
    • year 2 price = 103
    • year 3 price = 106.09
    • year 4 price = 109.27
    • year 5 price = 112.55
    • lifetime total = 530.91
If I could use a for loop in the formula editor I could calculate the lifetime total, but I can't figure out how to do that in the formula editor. Is there a way to do that or to write the for loop in an apex class and use that to populate the lifetime total field? I have no clue how to track each year's price espically when the term will vary.

Thank you for your time and help.
<id,Sobject> map1 = <id, Sobject>();
<id,Sobject> map2 = <id, Sobject>();

if map1 and map2 contain same key with different values.
how to add map2 values to map1 without deleting map1 values.
Hi,

I have a requriment to create list view from VF page.

Is there any way to create listview from apex
trigger for updating a value depending on another object field.
A very simple trigger.
I want to update by incrementing the total_applicant(Type:Number, object: Job__c) field by 1, which is to be done only after a record is inserted or updated in the Candidate__c object.
I can't figure out why line 7 is always red(errorneous) which leads to no change in the databse.
A little help would be appreciated. A newbiew here by the way.
I want to be able to create a Case and when the Case is created automatically link a File or Attachment.

I have a word document that I want attached to cases when they are created.

What is the best way to achieve this? Presumably it will require Apex code? Will I need to make a copy of the Word document from somewhere then create the required File records to attach it to the Case?
 
  • May 15, 2020
  • Like
  • 0
I am learning Apex and am trying to get my controller to query for Resource_List__c records where the Survey_Form__c field = :RecordId (the current Survery_Form__c record I am viewing)

VF Page
<apex:page Controller="ResourceListController">
    <apex:form>
    <apex:pageBlock>
<apex:pageBlockTable value="{! ResourceList }" var="RL">
    <apex:column value="{! RL.Id }"/>
    
</apex:pageBlockTable>
    </apex:pageBlock>
        </apex:form>
</apex:page>

Class
public class ResourceListController {
   public Id RecordId {get;set;}    
public List<Resource_List__c> getResourceList() {
    
    List<Resource_List__c> results = Database.query(
        'SELECT Id, Account__c, Distance__c, type__c ' +
        'FROM Resource_List__c ' + 
        'Where Survey_Form__c = :RecordId '
    );
    return results;
}
}

VF Page Output when on the Lightning page
User-added image
but when I put the query into the query editor and hard code the record Id there are values in this table

User-added image

Is there any way to pass the record id into the VF page without invoking aura or LWC? I just want to learn the fundamentals before I step into those new languages
Hi, I am working on the Account VisualForce page, and on that page I have a custom field that is from a different object. I am able to display that field from the different object but right now it is in a table. Is there a way to output the field value without a table, but just a single line of text? Below is what I have now, but only want the output to be a line of text, not in a table or anything else. The line below is already within an ouputPanel.Thanks.
 
<apex:pageBlockTable width="100%" cellpadding="1" cellspacing="1" 
                     value="{!contactList}" var="con" border="0" 
                     frame="none" id="table1">
    <apex:column>
        <apex:outputField value="{!con.CustomField__c}"
            rendered="{!con.CustomField__c != NULL}" 
        />
    </apex:column>
</apex:pageBlockTable>

 
Hi All !

I am trying to create a wrapper class , but in the VF page Iam getting error Unknown property 'String.DCode'. Any advice on this 


<apex:page controller="wrapperclass">
<apex:form>

<apex:pageBlock>
<apex:pageBlockSection>
<apex:pageBlockTable value="{!lstwrapperstring}" var="wrap">
<apex:column headerValue="Action">
<apex:inputCheckbox/>
</apex:column>

<apex:column headerValue="Deal Code"/>
{!wrap.DCode}

<apex:column headerValue="Course"/>
{!wrap.C}

<apex:column headerValue="Trainer First Name"/>
{!wrap.TFirstName}

<apex:column headerValue="Trainer Last Name"/>
{!wrap.TLastName}

<apex:column headerValue="Trainer Education"/>
{!wrap.TEducation}


</apex:pageBlockTable>



</apex:pageBlockSection>

</apex:pageBlock>

</apex:form>

</apex:page>


 
Hello All

Please find the below,   controller and a part of VF Page. Here the refresh not working when User clicks on Verify Asset button, the new one , which User has to enter is populating 3 Fields (Location, Warranty, Date) with the Previous entered Values. Please someone help in change of code or where have to change to get empty of those 3 fields on addition of new?

Thanks in Advance!
TrialHead Aspirant

VF Page:
========

 <apex:outputPanel rendered="{!renderAddAsset}">
                
                Model Number:<apex:inputText value="{!modelNumber}"/> 
                Serial Number:<apex:inputText value="{!serialNumber}"/>
                Install Date:<apex:input value="{!installDate}" 
                    html-placeholder="Install Date" 
                                              type="date"/>
                <apex:selectList label="Fields" value="{!selectedLocationId}" multiselect="false" size="1" >
                     <apex:selectOptions value="{!LocationSelections}" />
                </apex:selectList>
                In Warranty?<apex:selectList id="WarrantyStatusId" value="{!WarrantyStatus}" size="1">
                    <apex:selectOption itemValue="true" itemLabel="Yes"/>
                    <apex:selectOption itemValue="false" itemLabel="No"/>
                </apex:selectList> 
                 <apex:commandButton action="{!verifyAsset}" value="Verify Asset" reRender="apexform" status="spinnerStatus" styleclass="slds-button slds-button_brand"/>
                 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <apex:commandButton action="{!cancelAddAsset}" value="Cancel" reRender="apexform" status="spinnerStatus" styleclass="slds-button slds-button_brand"/>
            </apex:outputPanel>

Controller:
============
public PageReference verifyAsset(){
        resetError();
        Boolean hasErrors = false;
       
        
        if(modelNumber == '' || modelNumber == null){
            apexpages.addMessage(new ApexPages.message(Apexpages.Severity.ERROR,'Please enter model number.')); 
            hasErrors = true;
        }
        if(selectedLocationId == 'Select service location' ){
            apexpages.addMessage(new ApexPages.message(Apexpages.Severity.ERROR,'Please select a location.')); 
            hasErrors = true;
        }
        if(!string.isBlank(modelNumber)  && !modelNumber.isAlphanumeric() ){
            apexpages.addMessage(new ApexPages.message(Apexpages.Severity.ERROR,'Model Number can only contain alphanumeric characters.')); 
            hasErrors = true;
        }
        if(hasErrors){
            assetError = true;
            return null;
        }
        User-added image
display get response data in vf page, json response please help 

VF page :

<apex:page controller="RESTAPIJSONResponseController">
    <apex:form >
        <apex:pageBlock >            
            <apex:pageBlockButtons location="bottom">
                <apex:commandButton value="Fetch" action="{!fetchAPI}"/>
            </apex:pageBlockButtons>
        </apex:pageBlock>
        
        <apex:pageblock >
            <apex:pageBlockSection >
                <apex:pageBlockTable value="{!listWrapper}" var="obj">
                    <apex:column value="{!obj.rates}" headerValue="Id"/>
                    <apex:column value="{!obj.base}" headerValue="Login"/>
                    

 

                    
                </apex:pageBlockTable>
            </apex:pageBlockSection>
        </apex:pageblock>
    </apex:form>
</apex:page>

Controller: 
public with sharing class RESTAPIJSONResponseController {

    public List < JSONWrapper > listWrapper {get;set;}
    
    public RESTAPIJSONResponseController() {
        listWrapper = new List < JSONWrapper >();
    }
    
    public void fetchAPI() {
        HTTP h = new HTTP();
        HTTPRequest req = new HTTPRequest();
        req.setEndPoint('https://theforexapi.com/api/latest?HTTP/2');
        req.setMethod('GET');
        HTTPResponse res = h.send(req);  
        JSONParser parser = JSON.createParser(res.getBody());
        listWrapper = (List < JSONWrapper >) JSON.deSerialize(res.getBody(), List < JSONWrapper >.class);
        system.debug(''+res.getBody() );
        /*
           If the response contains only one value instead list, then you can use the below code
           JSONWrapper obj = (JSONWrapper) JSON.deSerialize(res.getBody(), JSONWrapper.class); 
           listWrapper.add(obj);
        */
    }
    
    public class JSONWrapper {
        
        public String base {get;set;}
        public String rates {get;set;}
        
    }
    
}

JSON Response :  in system.debug
"{\"date\":\"2021-07-07\",\"base\":\"EUR\",\"rates\":{\"USD\":\"1.1831\",\"JPY\":\"130.86\",\"BGN\":\"1.9558\",\"CZK\":\"25.688\",\"DKK\":\"7.4361\",\"GBP\":\"0.85500\",\"HUF\":\"355.57\",\"PLN\":\"4.5192\",\"RON\":\"4.9268\",\"SEK\":\"10.1813\",\"CHF\":\"1.0917\",\"ISK\":\"146.30\",\"NOK\":\"10.2475\",\"HRK\":\"7.4867\",\"RUB\":\"87.8009\",\"TRY\":\"10.2566\",\"AUD\":\"1.5711\",\"BRL\":\"6.1224\",\"CAD\":\"1.4708\",\"CNY\":\"7.6478\",\"HKD\":\"9.1900\",\"IDR\":\"17146.47\",\"INR\":\"88.2825\",\"KRW\":\"1344.89\",\"MXN\":\"23.5724\",\"MYR\":\"4.9241\",\"NZD\":\"1.6760\",\"PHP\":\"58.960\",\"SGD\":\"1.5924\",\"THB\":\"38.173\",\"ZAR\":\"16.8666\"}}"

Visualforce Error:
System.JSONException: Malformed JSON: Expected '[' at the beginning of List/Set
Error is in expression '{!fetchAPI}' in component <apex:commandButton> in page forexconv: Class.System.JSON.deserialize: line 15, column 1
Class.RESTAPIJSONResponseController.fetchAPI: line 16, column 1

Need to display This format :
Need to display this format
To This  Type : 
User-added image

Please Help With this Issue,
Thanks in Advance.




 
I'm creating a simple VFP to render as PDF and I would like to get some picklist fields. The problem is that I'm getting the API Name and not the label value. There's a way to do it using only VFP?

Example of how I'm doing:
Status: <br/>{!CPRMinutes__c.Status__c}

I tried the below trigger code but, getting  unexpected exception can anyone help.

trigger UpdateEmail on Contact (after insert, after update) {
    Set <String> AccId = New Set <String> (); 
    For (Contact con: Trigger.new){ 
        if (con.AccountId != Null ){ 
        AccId.add(con.AccountId); 
        } 
    } 
    List<Contact> con = [SELECT Id,LastName, Email, Account.Id FROM Contact WHERE Account.Id != null];
    List<Contact> newCon = new List<Contact>();
    for(Contact con: Trigger.new){
        Contact Cont = new Contact();
        Cont.Id = con.AccountId;
        Cont.Email = con.lastname+'@test.com';
        System.debug('Test'+Cont.Id);
        newCon.add(Cont);
    }
    update newCon;

}
 

Hi Everyone,

I'm passing a salesforce record that includes date fields to a Lightning compnent's helper class.  The page renders a Lightning datatable and displays the results as expected.  However, the page loads and runs very slow.  Looking at the console logs i can see a huge count of warnings, which i believe is the culprit.  The message that pops up for these logs is as follows:

"<lightning-formatted-date-time> The value attribute accepts either a Date object, a timestamp, or a valid ISO8601 formatted string with timezone offset. but we are getting the object value "Invalid Date" instead."

The Helper class defines the columns and teh formatting as:
{label: 'Ordered Date',     fieldName: 'Ordered_Date__c',           type: 'date', typeAttributes:{year: 'numeric', month:'numeric',day:'numeric'} }
The component utilises the datatable and renders the data correctly but very slow.  Here is the use of the datatable:
<lightning:datatable aura:id="datatable" data="{! v.data }" columns="{! v.columns }" >
The v.data receives the List<Object> from apex and the v.columns is defined in the helper.js class.

I'm guessing it's some issue with how JS and Apex communicate dates but i'm very new to JS so cannot figure out what the issue could be.  Very sorry if teh question is not detailed abundantly.  If someone can give some guidance it would be great, as i really want to rid this error.  It takes too long to load the page with anything more than a a hundred records.

Thanks
Aamir
  • April 02, 2021
  • Like
  • 0
Hello team,

after delete the record table in not refresh please help me regarding this.

below is my vf code
===================

     <div class="slds-col" style="margin-top:10px;">
                    <p style="font-weight:600; padding:10px;">Distributor / Retailer List</p>
                </div>
            </div>
           
            <div style="border:1px solid #ccc; margin-top:0px;" class="slds-scrollable_x"  >
                 <apex:outputPanel id="TablePanel">
                    <table class="slds-table slds-table_cell-buffer slds-table_bordered slds-table_col-bordered slds-table_striped">
                        <thead>
                            <tr class="slds-line-height_reset">
                                <th class="" scope="col">
                                    <div class="slds-truncate" title="">Account Name</div>
                                </th>
                                <th class="" scope="col">
                                    <div class="slds-truncate" title="">SF Customer Code</div>
                                </th>
                                <th class="" scope="col">
                                    <div class="slds-truncate" title="">SAP Customer Code</div>
                                </th>
                                <th class="" scope="col">
                                    <div class="slds-truncate" title="">Action</div>
                                </th>
                                
                            </tr>
                        </thead>
                        <tbody>
                           
                            <apex:repeat value="{!membs}" var="awl" >
                            <tr class="slds-hint-parent">
                                <th scope="row">
                                    <div class="slds-form-element__control">{!awl.Account__r.Name}</div>
                                </th>
                                <td data-label="" class="fromvalue">
                                    <div class="slds-form-element__control">{!awl.Account__r.SF_Customer_Code__c}</div>
                                </td>
                                <td data-label="" class="fromvalue">
                                    <div class="slds-form-element__control">{!awl.Account__r.SAP_Customer_Code__c}</div>
                                </td>
                               
                                <td data-label="">
                                     <apex:commandLink styleClass="slds-button slds-button_destructive"  value="Delete" action="{!showassigndel}" reRender="TablePanel" onclick="if(!confirm('Are you sure?')) return false;"  >
                                       <apex:param name="schemeId" value="{!awl.id}" assignTo="{!showdelId}"/>
                                    </apex:commandLink>
                                </td>
                            </tr>
                            </apex:repeat>
                                
                        </tbody>
                        
                        <tbody>
                            <apex:repeat value="{!searchList }" var="swl" >
                                <tr class="slds-hint-parent">
                                    <th scope="row">
                                        <div class="slds-form-element__control">{!swl.Account__r.Name}</div>
                                    </th>
                                    <td data-label="" class="fromvalue">
                                        <div class="slds-form-element__control">{!swl.Account__r.SF_Customer_Code__c}</div>
                                    </td>
                                    <td data-label="" class="fromvalue">
                                        <div class="slds-form-element__control">{!swl.Account__r.SAP_Customer_Code__c}</div>
                                    </td>
                                    
                                    <td data-label="">
                                        <apex:commandLink styleClass="slds-button slds-button_destructive"  value="Delete" action="{!Remove}" reRender="TablePanel">
                                            <apex:param name="schemeIdParam" value="{!swl.id}" assignTo="{!delId}"/>
                                        </apex:commandLink>
                                        
                                    </td>
                                </tr>
                            </apex:repeat>
                        </tbody>
                    </table>
                </apex:outputPanel>
            </div>
User-added imageHi Team,

I want to display error mesg when we select 'Other-Explain'.
<apex:page showHeader="false" action="{!InitMethod}" cache="false" controller="AH_HN_PhysicianAcceptnReject_CLS" tabStyle="Case">
    <apex:includeScript value="/soap/ajax/36.0/connection.js"/>
    <apex:includeScript value="/soap/ajax/36.0/apex.js"/>
    <apex:includeLightning />
    <apex:Pagemessages />
    
    <head>
        <apex:slds />
        <div class="slds-align_absolute-center">
            <apex:image url="{!$Resource.AH_Physician_Expert_Template_Logo}" />
        </div>
    </head>
    
    <apex:form >
        <div class="slds-align_absolute-center">
            
            <apex:outputText rendered="{!ThanksmsgAccpt}">
                <span style="font-size:20px;font-weight:bold;" class="slds-m-top_xx-large">Thank you for accepting, the case has now been added to your dashboard.  Please log into the physician portal to begin your review.</span>
            </apex:outputText> 
            
            <!--
<apex:outputText rendered="{!ThanksmsgRejec}">
<span style="font-size:20px;font-weight:bold;" class="slds-m-top_xx-large">Thank you for rejecting the case.<br/> </span>
</apex:outputText>
-->
            
            
            <apex:outputText rendered="true">
                <apex:pageBlock >
                    <!-- span style="font-size:20px;font-weight:bold;" class="slds-m-top_xx-large">Thank you for rejecting the case.<br/><br/> </span -->
                    
                    <p>Please select the reason:</p>
                    <apex:actionRegion >
                    <apex:selectList id="Pleaseselectthereason" size="1" label="caseRejectReason"  value="{!caseRejectReason}">
                        <apex:selectoption itemLabel="Out of office-cannot complete due to existing workload" itemValue="Out of office-cannot complete due to existing workload"></apex:selectoption>
                        <apex:selectoption itemLabel="I recommend another physician more suitable for this case.Enter Name in Free Text Box" itemValue="I recommend another physician more suitable for this case.Enter Name in Free Text Box"></apex:selectoption>
                        <apex:selectoption itemLabel="Other - explain" itemValue="Other - explain"></apex:selectoption>
                        <!--<apex:actionSupport event="onchange" reRender="comments" />-->
                    </apex:selectList>
                    </apex:actionRegion>
    
                    <br/>
                    
                    <p>Comments:</p>
                    <apex:inputTextarea label="Comments" style="width:550px;height:100px" id="comments" value="{!caseRejectComment}"/> 
                    
                    <br/><br/>
                    
                    <div align="center" draggable="false" >
                        <apex:commandButton action="{!saveRejectInfo}" value="Save"/>
                    </div>
                    
                </apex:pageBlock>
            </apex:outputText>
            
            <apex:outputText rendered="{!rejectreasonmessage}">
                <span style="font-size:20px;font-weight:bold;" class="slds-m-top_xx-large">Thank you for rejecting the case.</span>
            </apex:outputText>
            
            
            
            
            <apex:outputText rendered="{!Assignedtoothers}">
                <span style="font-size:20px;font-weight:bold;" class="slds-m-top_xx-large">This case has already been assigned to some other physician.</span>
            </apex:outputText>
            <apex:outputText rendered="{!AlreadyAccepted}">
                <span style="font-size:20px;font-weight:bold;" class="slds-m-top_xx-large">You have already accepted the case.</span>
            </apex:outputText>
            <apex:outputText rendered="{!AlreadyRejected}">
                <span style="font-size:20px;font-weight:bold;" class="slds-m-top_xx-large">You have already rejected the case.</span>
            </apex:outputText>
        </div>   
        
        
    </apex:form>
</apex:page>
                                        
Regards,
Isha
I added a visualforce page into lightning tab, and want page to look like same as lightning detail page, but it doent fit properly. Beginer developer and need help please. Also not able to get inline editing 
User-added imagemy code
<apex:page standardController="Opportunity" lightningStylesheets="true"> <apex:form > <apex:pageblock mode="maindetail"> <style> body .bPageBlock .pbBody .grey .pbSubheader{ background-color:grey; } </style> <apex:outputPanel styleClass="light grey" layout="block" > <apex:pageBlockSection title="Opportunity Basic Information" > <apex:InputField value="{!Opportunity.What_s_happening_today__c}"/> <apex:InputField value="{!Opportunity.What_do_I_want_to_achieve__c}"/> </apex:pageBlockSection> <apex:pageBlockSection title="Opportunity Goal/Size" > <apex:inputField value="{!Opportunity.Stretegic_Objective__c}"/> <apex:inputField value="{!Opportunity.Quantity__c}"/> <apex:inputField value="{!Opportunity.Product__c}"/> <apex:inputField value="{!Opportunity.Amount}"/> </apex:pageBlockSection>  </apex:outputPanel> <apex:inlineEditSupport event="ondblClick" showOnEdit="saveButton,cancelButton" hideOnEdit="editButton" /> <apex:commandButton action="{!save}" value="Save" Style="margin-left: 350px;"/> <apex:commandButton action="{!Cancel}" value="Cancel" Style="margin-left: 20px;"/> </apex:pageblock> </apex:form> </apex:page>

would like page to look like as below (stabdard detail page)

User-added image
global with sharing class products {
    @AuraEnabled
    public static List<PricebookEntry> getproduct() {

   List<PricebookEntry> prod= [SELECT Product2.Name, Unitprice FROM PricebookEntry];
  return prod;

    }
}

component--
<aura:component controller="products" > 
<aura:attribute name="productname" type="PricebookEntry[]"/>
<aura:attribute name="cols" type="List"/>  
     
    <aura:handler name="init" value="{!this}" action="{!c.doinit}"/>
   
    <lightning:datatable
            data="{!v.productname}"
            columns="{!v.cols}"
            keyField="Id"
            onrowaction="{!c.onRowAction}"/>
   
       
</aura:component>

controller---
({
	doinit : function(component) {
       component.set( 'v.cols' , [
            {
                'label': 'Name',
                'fieldName': 'Name',
                'type': 'text'
            },
{label': 'Price',
                'fieldName': 'Price',
                'type': 'Currency'
},
            {
                'label': 'Action',
                'type': 'button',
                'typeAttributes': {
                    'label': 'Add to Cart',
                    'name': 'view_details'
                }
            },
            {
                'label': 'Action',
                'type': 'button',
                'typeAttributes': {
                    'label': 'Buy',
                    'name': 'view_details'
                }
            }
            ]);
        
  var action = component.get("c.getproduct"); 
        // var self = this;
        action.setCallback(this, function(actionResult) {
            var state = actionResult.getState();
        if (state === "SUCCESS") {
          component.set("v.productname", actionResult.getReturnValue());
            component.set("v.productprice",actionResult.getReturnValue());
        }
            });
          $A.enqueueAction(action);
    },
		
	
})

Name and price of the products is not showing in datatable, but soql is executing successfully. What to do?
Eg:
const obj ={
  x:[
    {
      name:"Aruna",
      Position:"3"
    },
    {
      name:"Sri",
      Position:"1"
      }
]
};

How to perform sorting based on position in JavaScript
import { LightningElement } from 'lwc';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
import { loadStyle, loadScript } from 'lightning/platformResourceLoader';
import barcode from '@salesforce/resourceUrl/BarcodeJS'
import jdspdf from '@salesforce/resourceUrl/FusionJSpdf'
import FusionHTML2canvas from '@salesforce/resourceUrl/FusionHTML2canvas'
import Fusioncanvg from '@salesforce/resourceUrl/Fusioncanvg'
import Fusionrgbcolor from '@salesforce/resourceUrl/Fusionrgbcolor'

export default class PdfTest extends LightningElement {

    connectedCallback() {
        
       
        Promise.all([

           loadScript(this, Fusionrgbcolor  ),
           loadScript(this, barcode ) ,      
           loadScript(this, jdspdf  ) ,           
           loadScript(this, FusionHTML2canvas  ),
           loadScript(this, Fusioncanvg  )
           
            
       ]).then(() => {
            
           
           window.console.log('Files loaded.');
           var svgComponent = this.template.querySelector('svg');
           JsBarcode(svgComponent, '123123');
           
   
       }).catch( error => {
   
        if(error){

            window.console.log('Errors ' + error.message);

        }
        window.console.log('Errors ' );
           
           this.dispatchEvent(
               new ShowToastEvent({
                   title: 'Error updating record',
                   message: error,
                   variant: 'error'
               })
           );
       });
   
       }
}

Hi everyone.

 I am trying to load these external libraries that I have in separates static resource, It is only failing to load Fusioncanvg, I know that it depends on Fusionrgbcolor. I know that Fusionrgbcolor loads fine. 
How can load both?

Regards,
Carlos
<div class="col-md-7">
    <apex:inputSecret value="{!newPassword}" styleClass="form-control newPass formControl" />
</div>
<!--New Addition-->
<div class="panel conditionPanel" rendered="{!ISBLANK(newPassword)}">
    <ul class="list-unstyled font-12">
        <h5 class="font-12"><span class="glyphicon glyphicon-info-sign" /><strong>{!$Label.passwordmanage}</strong> </h5>
    </ul>
</div>

I wanted show next div only when user type something in new password
Hi guys,
i want to share with you a solution I come up with, to wrap long url when rendering a VF page.
Basically the problem was this:
A customer pasted a very long URL (more than 400 chars) in a Rich Text Area. When rendering the page as PDF, to print it, the URL overflow the page margin, so it wasn't visible at all.

This is the code i come up with
private String addWhiteSpaceInUrlTooLong(String text) {
        // Step 1 - Search anchor links
        Pattern ptn = Pattern.compile('<a[^>]*(>.*?)</a>'); // WATCH OUT! This regex doesn't match nested anchor
        Matcher mch = ptn.matcher(text);
        Integer charPerLine = 50; // A whitespace is inserted each charPerLine chars
        while (mch.find()) {
            String toReplace = mch.group(1);
            String substitute = '';
            Integer len = toReplace.length();

            if (len < charPerLine) //No need to replace
                continue;

            Integer elems; // White space to insert

            if (len / charPerLine == 0)
                elems = len / charPerLine;
            else
                elems = len / charPerLine + 1;

            // Insert white spaces
            for (Integer i = 1; i <= elems; i++) {
                if ((charPerLine * i) < len)
                    substitute += toReplace.substring(charPerLine * (i - 1), charPerLine * i) + ' ';
                else
                    substitute += toReplace.substring(charPerLine * (i - 1), len) + ' ';
            }

            text = text.replace(toReplace, substitute);            
        }

        // Step 2 - Search pasted links
        ptn = Pattern.compile('\\b\\s(https?://\\S.*?)(\\s|$)');
        mch = ptn.matcher(text);
        charPerLine = 60;

        while(mch.find()) {
            String toReplace = mch.group();
            String substitute = '';
            Integer len = toReplace.length();

            if (len < charPerLine)
                continue;

            Integer elems;

            if (len / charPerLine == 0)
                elems = len / charPerLine;
            else
                elems = len / charPerLine + 1;

            // Insert white spaces
            for (Integer i = 1; i <= elems; i++) {
                if ((charPerLine * i) < len)
                    substitute += toReplace.substring(charPerLine * (i - 1), charPerLine * i) + ' ';
                else
                    substitute += toReplace.substring(charPerLine * (i - 1), len) + ' ';
            }

            text = text.replace(toReplace, substitute);
        }

        return text;
    }

You could use like this:
MyCustomObject.richText = addWhiteSpaceInUrlTooLOng(MyCustomObject.richText);
Hope it will be useful ;)
 
Hi.

In the VF I used the date format as YYYY-MM-dd in the 
<apex:outputText value="{0,date,YYYY/MM/dd}">
Before the last week of the year it was OK. When the new year falls in the  last week of Decemeber comes the issue.
For example
2014:
S   M  T  W Th F Sat
28 29 30 31 1   2 3

In the above calendar 1st Jan of 2015 falls in the Thurusday.So when I viewd the records of 28,29,30 of December 2014 It showed as
2015-12-28
2015-12-29
2015-12-30
2015-12-31

After that I came to know that
@"YYYY" is week-based calendar year.
@"yyyy" is ordinary calendar year.
http://realmacsoftware.com/blog/working-with-date-and-time

cheers
suresh