• Jessica Riffe
  • NEWBIE
  • 109 Points
  • Member since 2015

  • Chatter
    Feed
  • 2
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 26
    Replies
 writing the unit test for deactivate user method,in the code after giving the run.As  for the current user, i gave it for the user I am deleting. So it is giving the error of INACTIVE_OWNER_OR_USER,  pls guide
Hi there, I've got a very specific design outcome I'm trying to achieve in Lightning and I can't find any info relating to this on any of the usual channels.

I want to present a flow as a modal dialog box from a list view. This would mean a user could select multiple records, and run through the flow for each of the items. I have built a version that meets these criteria with the exception of presenting the flow in a modal dialog over the current list. Although this final requirement isn't critical to the functionality of the process, it is important to keep the experience consistent with other lightning processes.

I understand this could be completed through JS if I was using Classic, but our org has migrated to Lightning a while back and won't be moving.

Also, interestingly I can get the desired modal display using an Action, but this can't be added to a list view (only a detail view) in my understanding.


Does anyone have any suggestions as to how this could be achieved? Thanks in advance!




This is the current process:

Visualforce Page, launched by list view button
<apex:page standardController="Contact" lightningStyleSheets="true" tabStyle="Contact" recordSetVar="AllContacts" >
        <!-- Add below each field you reference in your Flow -->   
        <apex:repeat value="{!AllContacts}" var="row" rendered="false">
            {!row.Id}
        </apex:repeat>
        <!-- Runs your Flow -->   
        <flow:interview name="Outbound_Call_Flow_Contact_v2" 
            finishLocation="{!URLFOR($Action.Contact.Tab, $ObjectType.Contact)}">
            <apex:param name="selectedContacts" value="{!Selected}"/>
        </flow:interview>
</apex:page>

Button settings
User-added image


List view
User-added image


Flow once launched (takes its own page, when I would like it to present modally)
User-added image

Desired presentation of flow
User-added image 
An internal server error has occurred
An error has occurred while processing your request. The salesforce.com support team has been notified of the problem. If you believe you have additional information that may be of help in reproducing or correcting the error, please contact Salesforce Support. Please indicate the URL of the page you were requesting, any error id shown on this page as well as any other related information. We apologize for the inconvenience. 

Thank you again for your patience and assistance. And thanks for using salesforce.com! 

Error ID: 622001247-7550 (-697924050)

*****************************************************************

I receive this error message when trying to load the change set details page.

I tried to log a case with Salesforce.  Seems as though I was directed here and wasn't able to edit any of the case content to fill out the required fields... like Description.  Not sure how you guys could help me.  But if anyone has some insight, that'd be great.  Deployments were working fine yesterday.  I cloned my changeset to upload to production, that didn't work.  Create a brand new change set to upload to production and that didn't work.  So I went to the partial sandbox and created a new change set from there and uploaded it as well, and that also didn't work.  

Thanks
I have created an action for Salesforce1 on the Account Record.  This action is to create an Opportunity record using the Action Layout and default values I have defined in the action.  This works great.

However, upon save of the new Opportunity record, I am redirected back to the account instead of the new record I created.  Is there a way I can change this without having to completely recreate the process in visual force or lightning?
I have created a class that runs on the before insert of a custom object.  The purpose is that, if the newly inserted recrod is one of the Integration Users, change the owner to the Agent custom field on the record.
 
public static void UpdateIntegrationOwnerToAgent(List<Productivity_Data__c> data)
    {
        Id profileId = userinfo.getProfileId();
        String ProfileName = [SELECT Name FROM Profile WHERE Id =: profileId LIMIT 1].Name;
        for(Productivity_Data__c d : data)
        {
            system.debug('### ' + d.OwnerId);
            if(ProfileName == 'Integration User')
            {
                system.debug('### Agent: ' + d.Agent__c);
                system.debug('### isActive: ' + d.Agent__r.IsActive);
                if(d.Agent__c != null && d.Agent__r.isActive)
                {
                    d.OwnerId = d.Agent__c;
                } 
            }
        }
    }

As I'm writing my test code, my assertion is failing because the user that I created for the agent field has isActive set to false.  It is my understanding that when you create a user in test methods, they are active.  And this is generally the case, however, my check on the agent__r.IsActive is returning false, therefore not hitting my code that changes the user.
 
public static User getAgent(Boolean xCommit)
    {
        Profile prof = [SELECT Id FROM Profile WHERE Name='AWD Sales'];
        
        User agent = new User();
        agent.Alias = 'standt';
        agent.Email = 'standarduser@testorg.com'; 
        agent.EmailEncodingKey = 'UTF-8';
        agent.LanguageLocaleKey = 'en_US'; 
        agent.LocaleSidKey='en_US';
        agent.TimeZoneSidKey='America/Los_Angeles';
        agent.UserName = 'TestProductivityData@Test.com';
		agent.FirstName = 'Test Agent';
		agent.LastName = 'Integration Test';
		agent.Agent_ID__c = '1234';
        agent.ProfileId = prof.Id;
        
        if(xCommit)
			insert agent;
        return agent;
    }
    
    public static testMethod void Test01TestIntegrationUserChangeToAgent()
    { 
        Profile prof = [SELECT Id FROM Profile WHERE Name = 'Integration User'];
        User intUser = [SELECT Id FROM User WHERE ProfileId =: prof.Id LIMIT 1];
        
        User a = getAgent(true);
        
        List<Productivity_Data__c> pData = generateTestData(5, false);
        
        for(Productivity_Data__c p : pData)
        {
            p.Agent__c = a.Id;
            //p.AgentId__c = a.Agent_ID__c;
            p.OwnerId = intUser.Id;
        }
        Test.startTest();
        system.runAs(intUser)
        {
        	insert pData;
        }
        Test.stopTest();
        
        List<Id> pDataIds = New List<Id>();
        for(Integer i = 0; i < pData.size(); i++)
        {
            pDataIds.add(pData[i].Id);
        }
        
        pData = [SELECT Id, OwnerId, Agent__c FROM Productivity_Data__c WHERE Id IN: pDataIds];
        
        system.assertEquals(a.Id, pData[0].OwnerId);
    }

Yes, I can get around this with adding an if statment to not check isActive when running the tests.  But I would prefer to not do that and have it be tested correctly.  This is coming from a trigger before insert method that takes in the trigger.new list.  Which means, I'm not querying this data, it is coming straight from the trigger, and I would assume.. the relationships should be available in the trigger information.

Thanks
Hello All,
I have a callback in a component help that is returning the id of a record from an apex class.
The name.id value is being returned.  I can see the id of the new record.  component.set('v.donor',name.Id)
But it is throwing an error after the record is saved.
Error in $A.getCallback() [Cannot set property 'checked' of null] Callback failed:
I am trying to return the new id to the cmp to enable the lightning:fileUpload button.  Its greyed out and I am assuming it will be enabled once it recognized an id.

How can I get the id from the controller helper js back to the .cmp to enable to the lightning:fileupload button?

Thanks,
P
Hello Experts,

We are developing a custom lighting web component where we have a requirement to show a set of custom action buttons. The same set of custom buttons are also added to the page layout of the custom object. We want show the buttons in the lightning web component only if those are added to the page layout. In other words - if the user removes any of the custom buttons from the page layout those options should be hidden from the lighting web component action button list as well.

So I am trying to see if I can access the page layout and its associted properties using Apex.

Could you please suggest if you have solved these type of requirements in any of your projects?

Thanks,
Bikram.
Lightning Application
<aura:application >
    <c:WrapperComponent/>
</aura:application>

Lightning component
<aura:component implements="flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId" access="global" controller="person" >
    <aura:attribute type="person.WrapperClass" name="testAttribute" />
    
    <lightning:input value="{!v.testAttribute.firstName}" name="first"/>
    
    <lightning:input value="{!v.testAttribute.lastName}" name="last"/>
                    <button class="slds-button slds-button_brand" onclick="{!c.submit}">Submit</button>

</aura:component>

Controller of component
({
	submit : function(component, event, helper) {
        
		 var action = component.get("c.getSuccess");
        action.setParams({ 
            obj : component.get('v.testAttribute')
        });
        
        action.setCallback(this, function(response) {
            var state = response.getState();
            if (state === "SUCCESS") {

                alert("From server: " + response.getReturnValue());

            }
            else if (state === "INCOMPLETE") {
                alert("From server : Sorry server call is incomplete");
            }
            else if (state === "ERROR") {
                var errors = response.getError();
                if (errors) {
                    if (errors[0] && errors[0].message) {
                        console.log("Error message: " + 
                                 errors[0].message);
                    }
                } else {
                    console.log("Unknown error");
                }
            }
        });
        $A.enqueueAction(action);
    }
	
})

Ape
global with sharing class person {
   
    
    public class WrapperClass {
    @AuraEnabled
        public String firstName;
    @AuraEnabled
        Public String lastName;        
}
    @AuraEnabled
    public Static String getSuccess(WrapperClass obj){
        String r ='';
        if(obj.firstName == 'text' && obj.lastName=='text')
        { r='hi';}
        
		return r;
        
    }    

}

x class
I have some triggers and classes that we no longer use that was pushed to production by the previous admin.  These codes have no coverage or don't meet the coverage requirement.

How would I remove these?  I've already tried Eclipse and Workbench but all came back with errors because of failed tests.
Hi all, 

I recently asked our web developer to add reCaptcha to the Web-to-Lead form on our website, as we have been dealing with an uptick in spam leads. We opted to use the reCaptcha v2 checkbox, since it is the simplest one to integrate.

However, when we enter the new code, with reCaptcha, generated in the SF web-to-lead setup, the reCaptcha widget does not render in the form. In addition, the form stops posting leads to Salesforce.

When we remove the reCaptcha code, the form starts working again.

Has anyone dealt with this problem before?

Thanks!

Meredith

 
Hi All,
I am facing Below error for my piece of code. Any suggestion / help is highly Appreciable.

Error:
Challenge Not yet complete... here's what's wrong:
There was an unexpected error in your org which is preventing this assessment check from completing: System.DmlException: Update failed. First exception on row 0 with id 5007F00000tAkWFQA0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, MaintenanceRequest: execution of AfterUpdate caused by: System.NullPointerException: Attempt to de-reference a null object Class.MaintenanceRequestHelper.cycleCalc2: line 23, column 1 Class.MaintenanceRequestHelper.updateWorkOrders: line 14, column 1 Trigger.MaintenanceRequest: line 7, column 1: []

Trigger:
trigger MaintenanceRequest on Case (after update, after insert) {
    Public List<Case> closedCase = new List<Case>();
    List<Case> caseA = [select ID, vehicle__c, equipment__c, date_due__c from Case Where Id IN :Trigger.new AND status ='Closed' and Type IN ('Repair', 'Routine Maintenance')];
    for(Case a : caseA) {
        closedCase.add(a);
    }
     MaintenanceRequestHelper.updateWorkOrders(closedCase); 
}

MaintenanceRequestHelper:

public class MaintenanceRequestHelper {
    Public Static List<Case> oldCase = new List<Case>();
    public static void updateWorkOrders(List<Case> closedCase){
        oldCase = closedCase;
        List<Case> newCase = new List<Case>();
            for (Case newCase2 : oldCase) {
                 newCase.add(new Case(type = 'Routine Maintenance',
                                status = 'New',
                                origin = 'Web',
                                Subject = null,
                                Date_Reported__c = date.today(),
                                Vehicle__c = newCase2.Vehicle__c,
                                Equipment__c = newCase2.Equipment__c,
                                Date_Due__c = cycleCalc2()));  
        }
        insert newCase;
    }

    private static Date cycleCalc2() {        
        oldCase = [select ID from Case Where status = 'Closed' and Type IN ('Repair', 'Routine Maintenance')];
        AggregateResult[] minCycleDay2 = [Select min(Equipment__r.Maintenance_Cycle__c) FROM Work_Part__c  WHERE Equipment__r.Maintenance_Cycle__c != null AND         Maintenance_Request__c IN: oldCase];
        Integer minCycleNum = ((Decimal)minCycleDay2[0].get('expr0')).intValue();
        Date returnDate = date.Today() + minCycleNum;
        return returnDate;
        }
    }

Please help.
Rgd's
Hi everyone,

Can anyone please guide my how to write a map<string> and list<string> together.please find below code and help me on this issue.

Map<String, Map<String, List<String>>> countryMap = new Map<String, Map<String, List<String>>> {'Germany' => 'German',  'Spain' => 'Spanish' ,  'France' => 'French' ,  'UnitedStates' => 'English' , 'UnitedStates' => 'Spanish' ,  'Canada' => 'English' , 'Canada' => 'French'};
            for(String c : newCountries){
                for(String l : newLanguages){
                    if(countrymap.containskey(c) && !Countrymap.get(c).contains(l)){
                        error = true;
                        account.adderror( 'country ' + c + ' does not support language ' + l);
                        return;
                    }
                }
            }

Thanks inadvance,
P.Balu
I want to display error messages based on certain validation below is the code

public class ProductSearchPopupController {
    
    public String query {get; set;}
    public List<PricebookEntry__c> products {get; set;}
    public List<wrapProduct> wrapProductList {get; set;}
    public List<PricebookEntry__c> selectedProduct{get;set;}
    public List<QuoteLineitem__c> quoteLineList{get;set;}
    public List<wrapProduct> selectedWrapperList{get;set;}
    public Boolean normalList{get;set;}
    public Boolean selectedList{get;set;}
    public Boolean block{get;set;}
    public Boolean block1{get;set;}
    public Boolean block2{get;set;}
    public String SalesPrice {get; set;}
    public integer Discount {get; set;}
    public String Quantity {get; set;}
    public String ServiceDate {get; set;}
    Id recordId;
    
    public ProductSearchPopupController(ApexPages.StandardController controller){
        recordId = controller.getId();
        system.debug('recordId '+recordId);
        wrapProductList = new List<wrapProduct>();
        selectedWrapperList = new List<wrapProduct>();
        normalList = true;
        selectedList = false;
        block = true;
        block1 = false;
        block2 = false;
    }
    
    public PageReference runQuery(){
        
        if(query == null || query == ''){
            if(query != 'recordid'){
                ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Info,'Invalid Entry'));}
                    else{
            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Info,'Please enter Product to search for'));
            
            return null;
            
        }
        }
                    
                    system.debug('query '+query);
 
            List<List<PricebookEntry__c>> searchResults=[FIND :query IN ALL FIELDS RETURNING PricebookEntry__c (id, Name, ProductCode__c, Product2Id__r.Product_Description__c,UnitPrice__c, UseStandardPrice__c)];
            if(searchResults[0]!=null){
                for(PricebookEntry__c a: searchResults[0]) {
                    // As each Account is processed we create a new wrapAccount object and add it to the wrapAccountList
                    wrapProductList.add(new wrapProduct(a));
                    block = true;
                    block1 = true;
                    block2 = false;
                }
            }
            return null;
        }
        
        
        public PageReference ProceedWithSelectedToNextPage(){
            selectedWrapperList = new List<wrapProduct>();
            normalList = false;
            selectedList = true;
            for(wrapProduct selectedWrapObj: wrapProductList){
                system.debug('selectedWrapObj.selected  ---------'+selectedWrapObj.selected);
                if(selectedWrapObj.selected == true)
                    selectedWrapperList.add(selectedWrapObj);
            }
            system.debug('selectedWrapperList size ---------'+selectedWrapperList.size());
            PageReference pageRef = new PageReference('/apex/AccountOpportunityTwoPage');
            pageRef.setRedirect(false);
            return pageRef;
        }
        public void processSelected() {
            selectedProduct = new List<PricebookEntry__c>();
            for(wrapProduct wrapProductObj : wrapProductList) {
                if(wrapProductObj.selected == true) {
                    selectedProduct.add(wrapProductObj.acc);
                    block = false;
                    block1 = false;
                    block2 = true;
                    
                }
            }
        }
        
        public void GoBack() {
            block = true;
            block1 = true;
            block2 = false;
        }
        
        public class wrapProduct{
            public PricebookEntry__c acc {get;set;}
            public Boolean selected {get;set;}
            public wrapProduct(PricebookEntry__c p) {
                this.acc = p;
                this.selected = false;
            }
            
        }
        
        public pagereference saveproduct(){
            List<QuoteLineitem__c> quoteLineList = new  List<QuoteLineitem__c>();
            if(!selectedProduct.isEmpty()){
                for(PricebookEntry__c sp:selectedProduct){
                    system.debug('sp '+sp);
                    QuoteLineitem__c qli = new QuoteLineitem__c();
                    qli.QuotesId__c = recordId;
                    qli.ListPrice__c = sp.UnitPrice__c;
                    qli.UnitPrice__c = sp.UnitPrice__c;
                    qli.Product2Id__c = sp.Product2Id__c;    
                    if(Discount!=0 || Discount!=null){
                        qli.Discount__c = Discount;
                    }
                    quoteLineList.add(qli);
                }
                
                if(quoteLineList.size()>0){
                    insert quoteLineList;
                    PageReference pageRef = new PageReference('https://proseraa.lightning.force.com/lightning/r/Quotes__c/'+recordId+'/view');
                    pageRef.setRedirect(true);
                    return pageRef;
                }
            }
            return null;
        }
        
    }

User-added image
Hi 

I am tryting to add error message as invalid data is the product does not exist. Can anyone help me with the same.

public class ProductSearchPopupController {
   
    public String query {get; set;}
    public List<PricebookEntry__c> products {get; set;}
    public List<wrapProduct> wrapProductList {get; set;}
    public List<PricebookEntry__c> selectedProduct{get;set;}
    public List<QuoteLineitem__c> quoteLineList{get;set;}
    public List<wrapProduct> selectedWrapperList{get;set;}
    public Boolean normalList{get;set;}
    public Boolean selectedList{get;set;}
    public Boolean block{get;set;}
    public Boolean block1{get;set;}
    public Boolean block2{get;set;}
    public String SalesPrice {get; set;}
    public integer Discount {get; set;}
    public String Quantity {get; set;}
    public String ServiceDate {get; set;}
    Id recordId;
   
    public ProductSearchPopupController(ApexPages.StandardController controller){
        recordId = controller.getId();
        system.debug('recordId '+recordId);
        wrapProductList = new List<wrapProduct>();
        selectedWrapperList = new List<wrapProduct>();
        normalList = true;
        selectedList = false;
        block = true;
        block1 = false;
        block2 = false;
    }
   
    public PageReference runQuery(){
        if(query == null || query == ''){
            system.debug('query '+query);
            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Info,'Please enter Product to search for'));
           
            return null;
        }
       
        system.debug('query '+query);
   
   if query = "qwertyuiopasdfghjklzxcvbnm" then
   system.debug('query '+query);
            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Info,'Please enter Product to search for'));
           
            return null;
        }
       
        system.debug('query '+query);
       
        List<List<PricebookEntry__c>> searchResults=[FIND :query IN ALL FIELDS RETURNING PricebookEntry__c (id, Name, ProductCode__c, Product2Id__r.Product_Description__c,UnitPrice__c, UseStandardPrice__c)];
        if(searchResults[0]!=null){
            for(PricebookEntry__c a: searchResults[0]) {
                // As each Account is processed we create a new wrapAccount object and add it to the wrapAccountList
                wrapProductList.add(new wrapProduct(a));
                block = true;
                block1 = true;
                block2 = false;
            }
        }
        return null;
    }
    public PageReference ProceedWithSelectedToNextPage(){
        selectedWrapperList = new List<wrapProduct>();
        normalList = false;
        selectedList = true;
        for(wrapProduct selectedWrapObj: wrapProductList){
            system.debug('selectedWrapObj.selected  ---------'+selectedWrapObj.selected);
            if(selectedWrapObj.selected == true)
                selectedWrapperList.add(selectedWrapObj);
        }
        system.debug('selectedWrapperList size ---------'+selectedWrapperList.size());
        PageReference pageRef = new PageReference('/apex/AccountOpportunityTwoPage');
        pageRef.setRedirect(false);
        return pageRef;
    }
    public void processSelected() {
        selectedProduct = new List<PricebookEntry__c>();
        for(wrapProduct wrapProductObj : wrapProductList) {
            if(wrapProductObj.selected == true) {
                selectedProduct.add(wrapProductObj.acc);
                block = false;
                block1 = false;
                block2 = true;
               
            }
        }
    }
   
    public void GoBack() {
        block = true;
        block1 = true;
        block2 = false;
    }
   
    public class wrapProduct{
        public PricebookEntry__c acc {get;set;}
        public Boolean selected {get;set;}
        public wrapProduct(PricebookEntry__c p) {
            this.acc = p;
            this.selected = false;
        }
       
    }
   
    public pagereference saveproduct(){
        List<QuoteLineitem__c> quoteLineList = new  List<QuoteLineitem__c>();
        if(!selectedProduct.isEmpty()){
            for(PricebookEntry__c sp:selectedProduct){
                system.debug('sp '+sp);
                QuoteLineitem__c qli = new QuoteLineitem__c();
                qli.QuotesId__c = recordId;
                qli.ListPrice__c = sp.UnitPrice__c;
                qli.UnitPrice__c = sp.UnitPrice__c;
                qli.Product2Id__c = sp.Product2Id__c;    
                if(Discount!=0 || Discount!=null){
                    qli.Discount__c = Discount;
                }
                quoteLineList.add(qli);
            }
           
            if(quoteLineList.size()>0){
                insert quoteLineList;
                PageReference pageRef = new PageReference('https://proseraa.lightning.force.com/lightning/r/Quotes__c/'+recordId+'/view');
                pageRef.setRedirect(true);
                return pageRef;
            }
        }
        return null;
    }
   
}

VF Code

<apex:page standardController="Quotes__c" extensions="ProductSearchPopupController" showHeader="false" sidebar="false" lightningStylesheets="true">
    <apex:form id="form">
        <apex:pageMessages ></apex:pageMessages>
   
        <div style="width 100%">
            <apex:pageBlock title="Add Products" id="block" rendered="{!block}"> 
                <centre>
                    <apex:pageBlockSection columns="1" id="section"> 
                        Enter the product to be added and select Go<br/>
                        <apex:inputText value="{!query}" id="query"/> 
                    </apex:pageBlockSection> 
                </centre>
                <apex:commandButton value="Go" action="{!runQuery}"/>
                <apex:commandButton value="Cancel" action="{!cancel}"/>
            </apex:pageBlock>
            <apex:pageBlock id="block1" rendered="{!block1}" >
                <apex:pageBlockSection columns="1">
                    <apex:pageBlockTable value="{!wrapProductList}" var="accWrap">
                        <apex:column >
                            <apex:facet name="header">
                                <apex:inputCheckbox onclick="selectAllCheckboxes(this,'inputId')"/>
                            </apex:facet>
                            <apex:inputCheckbox value="{!accWrap.selected}" id="inputId"/>
                        </apex:column>
                        <apex:column headerValue="Name">
                            <apex:outputLink value="#">{!accWrap.acc.Name}</apex:outputLink>       
                        </apex:column>
                        <apex:column headerValue="Product Code">
                            <apex:outputText value="{!accWrap.acc.ProductCode__c}"  />       
                        </apex:column>
                        <apex:column headerValue="Product Description">
                            <apex:outputText value="{!accWrap.acc.Product2Id__r.Product_Description__c}"  />       
                        </apex:column>
                        <apex:column headerValue="Unit Price">
                            <apex:outputText value="{!accWrap.acc.UnitPrice__c}"  />  
                        </apex:column>
                        <apex:column headerValue="Standard Price">
                            <apex:outputText value="{!accWrap.acc.UseStandardPrice__c}"  />  
                        </apex:column>
                    </apex:pageBlockTable>  
                    <apex:commandButton value="Next" action="{!processSelected}"/>  
                </apex:pageBlockSection>
            </apex:pageBlock>
        </div>
        <div>
            <apex:pageBlock id="block2" rendered="{!block2}" >
                <apex:pageblockSection title="All Products" collapsible="false" columns="3">
                    <apex:pageBlockTable value="{!selectedProduct}" var="c" id="table2" title="Selected Products">
                        <apex:column value="{!c.Name}" headerValue="Product Name"/>
                        <apex:column headerValue="Sales Price">
                            <apex:inputText value="{!c.UnitPrice__c}" id="UnitPrice" /> 
                        </apex:column>
                        <apex:column headerValue="Discount">
                            <apex:inputText value="{!discount}" id="discount" /> 
                        </apex:column>
                        <apex:column headerValue="Quantity">
                            <apex:inputText value="{!quantity}" id="quantity" /> 
                        </apex:column>
                    </apex:pageBlockTable>  
                </apex:pageblockSection>
                <apex:commandButton action="{!GoBack}" value="Back"/>
                <apex:commandButton action="{!saveproduct}" value="Save"/>
                <apex:commandButton value="Cancel" oncomplete="doRedirect();"/>           
            </apex:pageBlock>
        </div>
    </apex:form>
</apex:page>
setScale(2) doesn't work for me. If the amount is 53, i want 53.00, if it is 53.1, i want it to show as 53.10 but currently it shows as only 53 or 53.1, it cuts off the zero.

Please see my code below;

public class BillAndPayWrapper {
        @AuraEnabled public DateTime postDate;
        @AuraEnabled public String   billPeriod;
        @AuraEnabled public Boolean  showSuccess;
        @AuraEnabled public String      invoice;
        @AuraEnabled public Decimal  amount;
        @AuraEnabled public String      amount_formatted;
        @AuraEnabled public String   docType;
        @AuraEnabled public String      pdfDocURL;
       
        BillAndPayWrapper(BillingHistoryServiceSet__x billPay, String companyCode) {
            this.postDate      = billPay.PostingDate__c;
            this.invoice      = billPay.InvoiceNo__c;
            this.amount      = billPay.TotalDueAmt__c.setScale(2);
            this.billPeriod  = billPay.BillPeriod__c;
            this.billPeriod = this.billPeriod.right(2) + '/' + this.billPeriod.left(4);

            if (amount<0) {
                amount=amount*-1;
                this.amount_formatted = '($' + String.valueOf(amount.format()) + ')';
                showSuccess=true;
            }
            else  this.amount_formatted = '$' + String.valueOf(amount.format());

please note: external object amount field data type is number
Hi All,
For Apex Specialist-Challange 1, I am facing below error.

"Challenge Not yet complete... here's what's wrong:
Inserting a new Maintenance Request of type 'Routine Maintenance' and then closing it did not create of a new Maintenance Request based upon the original record correctly. The challenge is expecting to find the closed Maintenance Request plus an 'New' Maintenance Request of type 'Routine Maintenance' with the same Vehicle as the closed one."

Below is my Code:
trigger MaintenanceRequest on Case (before update,after update) 
{
    if (TriggerHelperClass.MyBool==TRUE) 
        {
           MaintenanceRequestHelper.updateWorkOrders();
           TriggerHelperClass.MyBool=FALSE;
        }       
}

wMaintenanceRequestList= new List<Case>();
   for(Case cas:maintenanceRequestList){
     if(cas.Type=='Routine Maintenance' &&  cas.Status=='Closed'){
       case newMaintenanceRequest=new Case();
       newMaintenanceRequest.Subject='test';
       newMaintenanceRequest.Type='Routine Maintenance';
       newMaintenanceRequest.Vehicle__c= cas.Vehicle__c;
       newMaintenanceRequest.Equipment__c = cas.Equipment__c;
       newMaintenanceRequest.Date_Reported__c =date.Today();
       newMaintenanceRequest.Date_Due__c=Date.today().addDays(Integer.valueOf(cas.Equipment__r.Maintenance_Cycle__c));
       newMaintenanceRequest.Status='New';
       newMaintenanceRequest.Origin='Phone';
       newMaintenanceRequestList.add(newMaintenanceRequest);
     }
   }
       return newMaintenanceRequestList;
  }
}

public class TriggerHelperClass
{
    Public static boolean MyBool=TRUE;
}

When Boolean Variable was not Introduced, Code was going in Loop, to avoid loop added Boolean variable. Please suggest reason of error & if possible sol. for same.

Rgd's
Vineet Anand
Hi,
my custom object has a lookup with USer object-- createdBY
i am trying to fetch the data from custom object as
createdby.name but the field is not fetching, please help with this.
Thanks
 writing the unit test for deactivate user method,in the code after giving the run.As  for the current user, i gave it for the user I am deleting. So it is giving the error of INACTIVE_OWNER_OR_USER,  pls guide
I am done almost but when i check the challenge it shows me the message please help me to complete this task.Create and enable a compact layout i am facing problem to accomplish

YOUR CHALLENGE
Create and enable a compact layout
Brokers want to see important information about their showings at a glance. Create and implement a new compact layout for accounts.
Create a new account compact layout
Label: Mobile Account Layout
Name: Mobile_Account_Layout
Selected fields: Account Name, Annual Revenue, Phone, Type
Make the new Mobile Account Layout the primary compact layout for accounts