• imrohit
  • NEWBIE
  • 55 Points
  • Member since 2018
  • Salesforce Developer
  • Cloud Certitude

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 28
    Questions
  • 22
    Replies

I have created a batch class to generate excel file of salesforce records, data to generate in excel is aroud 2-3 lakhs but every time batch class fails with CPU time limit exceed or Apex Heap size issue.

Please help if there is another way to achieve this.

Hi

I have one vf page and  while redering it as excel I need to display one cell as dropdown with values, Is it possible?

Thanks in Advance.

 

Hello All,

I am trying to insert collaborationGroup and adding my users to this group but it is failing for some users and I am getting the above error.

Has anybody aware of this problem. Please help to sort this out.

Thanks in advance

Hi all, Can I have a full list of what are setup objects and what are non setup objects?

Is CollaborationGroup is Setup or non setup object?

would I get Mixed DML exception error if I try to insert CollaborationGroup and USer record in the same transaction?

Thanks in advance

Hello guys I have on lightning component which I override with New and Edit  button  of an object in salesforce lightning service console, so whenever I opened it first time it opens easily but if I closed it and try to reopen it the subtab opens but component is not able to load under the subtab to reload it I need to refresh the subtab everytime which I don't want.

please help  

Hi guys, I have one lightning record form which I am using to create new contact after overriding the contact's New button code below

<aura:component implements="lightning:actionOverride,force:hasRecordId"  access="global" >
    
    <aura:attribute name="fields"
                    type="String[]"
                    default="['FirstName', 'LastName','AccountId']"/>

    <lightning:card iconName="custom:custom19" title="lightning:recordForm">
        <div class="slds-p-left_large slds-p-right_medium">	
            
    <!-- Displays toast notifications -->
    
            <lightning:recordForm
                                  objectApiName="Contact"
                                  fields="{!v.fields}"
                                  />
        </div>
    </lightning:card>
</aura:component>


now I want whenever I create New contact from Account's related list the account should be auto-populated.
how can I do this please help

 User-added image when you click on the new contact from account's related list I want account as auto-populated
User-added image

I want output as this 

User-added imageThanks in advance

Hi All, I have one Email-to-case, Every time case is created whenever Email comes to me, what I want is that wherever the case is created from Email, the description is updated with some content like this
"See your Review .... 
https://www.trustpilot.com/reviews/5c98411897afa10bb8762e40"

of the Email body, My question is, Is there any way to fetch the
dynamically generated number (mentioned above) in the link from the content of the Email body and save it to one of the fields of the Case.

I have one object which has one field of checkbox type now my requirement is that at a time only one record in the object can have checkbox value as true so suppose If I save a record with checkbox value as true and then I create another record and trying to save record with checkbox as true so in this case validation rule should throw error.

thanks in advance

hi I have lightning flow which call apex and perform some logic and then apex returns the list of records which I need to display in lightning component in the lightning flow 

please suggest how can I do this 

thanks

I have three inputs in the flow screen and I am calling invocable apex from the flow since invocable apex accept only one input parameter so can you  please suggest me how can I sent my all three inputs to the apex as list of string so that there I can use them accordingly

Thanks in advance

I have screen flow with some input elements and after putting values in those input fields I want to call a trigger and want to get thsoe inputed values in my trigger so how can I do this can anyone help
Thanks in advance
since we cant use screen to show an error message in auto launched flow so I want another solution so that I can show the message on the screen on which you are creating record.
comment If you want further clarification

Thanks in advance 

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: 1310511833-349364 (-106741825)

Thanks in advance
public with sharing class bOQrenewClass {
    @AuraEnabled
    public static List<WrapperClass> getproducts(String productToSearch) {
        List<WrapperClass> wrapperList = new List<WrapperClass>();
		Map<String, List<SelectedRecordsModel>> stageMap = new Map<String, List<SelectedRecordsModel>>();               
        String newSearchText = '%'+productToSearch+'%';
        for(Product2 obj: [SELECT Id, Name, Quantity__c, total_amount__c, Price__c, Section__c FROM Product2 ]){//WHERE Name LIKE :newSearchText
            stageMap.put(obj.Section__c, null);           
        }
        
        for(Product2 obj: [SELECT Id, Name, Quantity__c, Price__c, total_amount__c, Section__c FROM Product2  ORDER BY Section__c ASC, Name ASC]) {   //WHERE Name LIKE :newSearchText                   
            List<SelectedRecordsModel> prodList = new List<SelectedRecordsModel>();
            
            if (stageMap.get(obj.Section__c) != null) {
                prodList = stageMap.get(obj.Section__c);
            }
            
            prodList.add(new SelectedRecordsModel(obj));      
            stageMap.put(obj.Section__c, prodList);
        }
                    
        for(String obj: stageMap.keyset()){
            WrapperClass wrapperObj = new WrapperClass();
            wrapperObj.Stage = obj;
            wrapperObj.productRenewList = stageMap.get(obj);
            wrapperList.add(wrapperObj);
        }
        
        return wrapperList;
    }
    
        public class WrapperClass {
        @AuraEnabled String Stage{get; set;}
        @AuraEnabled List<SelectedRecordsModel> productRenewList {get; set;}
        
    }
    public class SelectedRecordsModel {
        @AuraEnabled Boolean isSelected {get;set;}
        @AuraEnabled Product2 prd {get;set;}
        
        public SelectedRecordsModel(Product2 prd){
            this.prd = prd;
            isSelected = false;
        }
    }
}

component code
 <ui:inputText class="slds-input slds-size_4-of-12 slds-border_bottom " aura:id="search" placeholder="Type to search"
                  value="{!v.productToSearch}"
                  updateOn="keyup"
                  keyup="{!c.filterContacts1}" />
   

<aura:iteration items="{!v.newWrapperList}" var="obj" indexVar="i">                
            <tr class="slds-box slds-theme_shade ">
                <td colspan="5">
                    <lightning:formattedText value="{!obj.Stage}"/>
                </td>                   
            </tr>
            
                
                <aura:iteration items="{!obj.productRenewList}" var="iobj" indexVar="j" start="0">
                    
                    <tr class="html" >                           
                        <td >
                            <ui:inputCheckbox value="{!iobj.isSelected}" change="{!c.pushToList}" name="{!i+''+j}" />
                        </td>
                        <td>
                            <ui:outputText  value="{!iobj.prd.Name}" />
                        </td>                                                        
                        <td>
                            <lightning:input readonly="true" class="input-box slds-no-focus" style="border:none!important;" type="Number" value="{!iobj.prd.Price__c}"  />
                        </td>                            
                        <td>
                            <!-- <span onkeyup="{!c.performCalculation}">-->
                            <lightning:input class="input-box" type="Number" min="0" value="{!iobj.prd.Quantity__c}" onchange="{!c.performCalculation}" />
                            <!-- </span>-->
                        </td>                            
                        <td>
                            <lightning:input readonly="true" class="input-box slds-no-focus" style="border:none!important;" type="Number" value="{!iobj.prd.Total_Amount__c}"   />
                        </td>
                    </tr>
                </aura:iteration>
            
        </aura:iteration>

js controller code 
 
filterContacts1 : function(component, event, helper){
component.set("v.newWrapperList",arr);
        console.log("@@ "+ JSON.stringify(arr));*/
        var arr = new Array();
        var searchKey = component.get("v.productToSearch").toLowerCase();
        var allRecords = component.get("v.wrapperList");
        for(var i =0; i<allRecords.length;i++){
            var obj = allRecords[i];
            //console.log(JSON.stringify(obj));
            for(var j=0; j<allRecords[i].productRenewList.length;j++){
                //console.log(JSON.stringify(allRecords[i].productRenewList[j].prd.Name));
                var str = allRecords[i].productRenewList[j].prd.Name;
                if(str.toLowerCase().includes(searchKey))
                    arr.push(obj);
              
            }
        }
       // cmp.set("v.wrapperList",cmp.get("v.newWrapperList"));
        component.set("v.newWrapperList",arr);
}
as the code above, i have one apex, lightning component and js controller. I have properly bind that wrapper list to the component 
now the requirement is that i hve to place a filter record box in which i need to enter name of the product on keyup but there are some mistake i am edoing that on pressing the backspace key the records are again adding to list and the duplicates are showing on outpuut 
please help 

if you have any query you can comment
Thanks in advance
 
  • September 25, 2018
  • Like
  • 0
[  
   {  
      "Id":"a0F7F000006lv7OUAQ",
      "Name":"Lightning Arrester(ESE Type (50 m -3 Nos , 65m - 3 Nos , 100 m - 6 Nos , 107 m -",
      "Price__c":2998,
      "Stage__c":"Civil Works",
      "Quantity__c":"43"
   },
   {  
      "Id":"a0F7F000006lv7EUAQ",
      "Name":"Safety Lifelines",
      "Price__c":20,
      "Stage__c":"Civil Works",
      "Quantity__c":"45"
   }
]

i have records of custom object with apiname productRenew__c in json string formate and i want to convert this json to corresponding object so that i can save the records to the db

Please Help
Thanks in advance
  • September 08, 2018
  • Like
  • 0

<aura:iteration items="{!obj.productRenewList}" var="iobj">
                        <tr class="slds_line_height-small g" >                           
                            <td><ui:inputCheckbox value="{!iobj.isSelected}"/></td>
                            <td> <ui:outputText  value="{!iobj.prd.Name}" /> </td>                            
                            <td> <ui:outputText class="a" value="{!iobj.prd.Price__c}" /> </td>
                           
                            <td><lightning:input class="b" type="Number" value="{!iobj.prd.Quantity__c}" /></td>
                            <td><ui:outputText class="c" value="{!iobj.prd.Total_Amount__c }" /> </td>
                        </tr>
                    </aura:iteration>


i want to multiply price and quantity and store that value in totalamount field for each row.
please suggest the solution 

Thanks in advance
  • September 08, 2018
  • Like
  • 0
I am having  a problem  , i am showing record to the lightning component with checkboxes using the following apex code
public with sharing class bOQrenewClass {
    @AuraEnabled
    public static List<WrapperClass> getproducts() {
        List<WrapperClass> wrapperList = new List<WrapperClass>();
		Map<String, List<SelectedRecordsModel>> stageMap = new Map<String, List<SelectedRecordsModel>>();
       
        
        for(productRenew__c obj: [SELECT Id, Name, Quantity__c, Price__c, Stage__c FROM productRenew__c]){
            stageMap.put(obj.Stage__c, null);           
        }
        
        for(productRenew__c obj: [SELECT Id, Name, Quantity__c, Price__c, Stage__c FROM productRenew__c ORDER BY Stage__c ASC, Name ASC]) {                      
            List<SelectedRecordsModel> prodList = new List<SelectedRecordsModel>();
            
            if (stageMap.get(obj.Stage__c) != null) {
                prodList = stageMap.get(obj.Stage__c);
            }
            
            prodList.add(new SelectedRecordsModel(obj));      
            stageMap.put(obj.Stage__c, prodList);
        }
                    
        for(String obj: stageMap.keyset()){
            WrapperClass wrapperObj = new WrapperClass();
            wrapperObj.Stage = obj;
            wrapperObj.productRenewList = stageMap.get(obj);
            wrapperList.add(wrapperObj);
        }
        
        return wrapperList;
    }
    
   @AuraEnabled
    public static void performAction(List<WrapperClass> positionRecords) {       
       for(WrapperClass obj:positionRecords)
            {
                for(SelectedRecordsModel obj1: obj.productRenewList)
                if(obj1.isSelected)
                {
                    //Play with selected Records here                   
                    system.debug('Selected Record :'+obj1);
                }
            }      
    }
    public class WrapperClass {
        @AuraEnabled String Stage{get; set;}
        @AuraEnabled List<SelectedRecordsModel> productRenewList {get; set;}
        
    }
    public class SelectedRecordsModel {
        @AuraEnabled Boolean isSelected {get;set;}
        @AuraEnabled productRenew__c prd {get;set;}
        
        public SelectedRecordsModel(ProductRenew__c prd){
            this.prd = prd;
            isSelected = false;
        }
    }
}

and here is the component code
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" controller="bOQrenewClass">
    
    <aura:attribute name="wrapperList" type="object[]"/>
    
    
    <aura:handler name="init" value="{! this }" action="{! c.doInit }"/>
    
    <lightning:card  title="xyz">
        <table class="slds-table slds-table_bordered slds-max-medium-table_stacked-horizontal ">
            <thead>
                <tr class="slds-text-title--caps">
                    <th scope="col">
                        <div class="slds-truncate " title="Account Name">SELECT</div>
                    </th>
                    <th scope="col">
                        <div class="slds-truncate  " title="FIRsT Name">PRODUCT</div>
                    </th>
                    <th scope="col">
                        <div class="slds-truncate " title="Account Name">PRICE</div>
                    </th>
                    <th scope="col">
                        <div class="slds-truncate " title="Close Date">QUANTITY</div>
                    </th>
                    <th scope="col">
                        <div class="slds-truncate " title="Stage">TOTAL</div>
                    </th>      
                </tr>
            </thead>
            
            <aura:iteration items="{!v.wrapperList}" var="obj">
                
                <tr class="slds-box slds-theme_shade ">
                    <td colspan="5">{!obj.Stage}</td>
                   
                </tr>
                <tbody>
                <aura:iteration items="{!obj.productRenewList}" var="iobj">
                    <tr class="slds_line_height-small" >
                       <!-- <td><lightning:input type="checkbox"/></td>-->
                        <td><ui:inputCheckbox value="{!iobj.isSelected}"/></td>
                        <td> <ui:outputText value="{!iobj.prd.Name}" /> </td>
                       <!-- <td>{!iobj.prd.Name}</td>
                        <td>{!iobj.prd.Price__c}</td>-->
                         <td> <ui:outputText value="{!iobj.prd.Price__c}" /> </td>
                        <td><lightning:input type="Number" value="{!iobj.Quantity__c}" /></td>
                        <td><ui:outputText value="{!iobj.prd.Price__c * (iobj.prd.Quantity__c !=null ? iobj.prd.Quantity__c : 0)}" /> </td>
                    </tr>
                </aura:iteration>
                </tbody>
            </aura:iteration>
        </table>
         
            
            <lightning:button class="slds-theme_inverse slds-p-horizontal_xx-large"
                              aura:id="expenseform2" label="  SAVE  "
                              name="Mobile"
                              onclick="{!c.searchitems1}"/>    
                  	
    </lightning:card>
    
</aura:component>

here is the jscontroller
({
	
    searchitems1 : function(component, event, helper) {
        
       var selectedRecords = component.get("v.productRenewList");
        console.log(JSON.stringify(selectedRecords));
            var action = component.get("c.performAction");           
            action.setParams({
                positionRecords : selectedRecords
            });
            
           
            action.setCallback(this,function(a){                
                var state = a.getState();                
                if(state == "SUCCESS"){                                       
                    alert('Success in calling server side action');                    
                } else if(state == "ERROR"){
                    alert('Error in calling server side action');
                }
            });
            $A.enqueueAction(action);            
        },
  
    doInit : function(cmp,event,helper){
        //alert('hello');
        
        var action = cmp.get("c.getproducts");
        action.setCallback(this,function(response){
            var state = response.getState();
			//alert(JSON.stringify(response.getReturnValue()));
            if(state == "SUCCESS"){
                cmp.set("v.wrapperList", response.getReturnValue());
            }
            
        });
        $A.enqueueAction(action);
        
       
    }
})

the data is displaying properly on the component but when i select some checkbox and click on save i am not abeling to get those selected records to the debug of the apex method i am getting internal salesforce error for this

what changes should  i make to the code please help
  • September 07, 2018
  • Like
  • 0
Create a trigger, when an OpportunityLineItem is created (or is updated and the PricebookEntry has changed) set OpportunityLineItem.Can_Be_Recurring__c to PricebookEntry.Product2.Can_Be_Recurring__c.

 how can i do this 
please help
thanks
<aura:iteration items="{! v.fields }" var="field">
           
            <div class="slds-size_5-of-12">
                <lightning:input aura:id="idName"   label="{!field.Label}"  required="{!field.DBRequired}"  type="{!field.Type}" class="slds-p-top_small slds-m-top_medium" />
            </div>
             <div class="slds-size_1-of-12"></div>
            </aura:iteration>
and i want  ,whatever i type in input box of firstname,lastname or whatever  the value of that field should be store in attribute of type Contact otherwise i want all the data as Json in lightning component  Js controller  Please help me to solve this...
Hi, I am new to LWC ​​​​​​, trying dynamically add/remove rows for a table scenario. I can able to add the row by click on the + button. After added that rows I want to enter some values in text boxes and save into account object by click on save buttton. Also do the delete action as well to delete the specific row by click on delete button. 

I am facing issue with save & delete records. How I can solve this? Can anyone give me some guidence to solve.

AddDeleteRow
dynamicAddRow.html

<template>
                  
    <div class="slds-m-around--xx-large">
        <div class="slds-float_right slds-p-bottom_small">
            <h1 class="slds-page-header__title">Add Row
                <lightning-button-icon icon-name="utility:add"  size="large" variant="bare" alternative-text="Add" onclick={addRow}> </lightning-button-icon>
            </h1>
        </div>
        <div class="container-fluid">        
            <table class="slds-table slds-table_bordered slds-table_cell-buffer"> 
                <thead>
                    <tr class="slds-text-title_caps">
                        <th scope="col">
                            <div class="slds-truncate">#</div>
                        </th>
                        <th scope="col">
                            <div class="slds-truncate" title="Account Name">Account Name</div>
                        </th>
                        <th scope="col">
                            <div class="slds-truncate" title="Account Number">Account Number</div>
                        </th>
                        <th scope="col">
                            <div class="slds-truncate" title="Phone">Phone</div>
                        </th>
                        <th scope="col">
                            <div class="slds-truncate" title="Action">Action</div>
                        </th>
                    </tr>
                </thead>   
                <tbody>      
                    
                    <template for:each={accountList} for:item="acc" for:index="index">
                        <tr key={acc.Id}> 
                            <td>{index}</td>                                                  
                            <td>
                                <lightning-input label="Name" value={acc.Name} onchange={handleNameChange}></lightning-input>                               
                            </td>
                            <td>
                                <lightning-input label="Account Number" value={acc.AccountNumber} onchange={handleAccountNumberChange}></lightning-input>                        
                            </td>
                            <td>
                                <lightning-input label="Phone" value={acc.Phone} onchange={handlePhoneChange}></lightning-input>
                            </td>
                            <td>
                                <a onclick={removeRow}> 
                                    <lightning-icon icon-name="utility:delete" size="small" style="margin-top: -4px; margin-right: 0px;" ></lightning-icon>
                                    <span class="slds-assistive-text">Delete</span>
                                </a>
                            </td> 
                        </tr>
                    </template>
                     
                </tbody>
            </table>
            <div class="slds-align_absolute-center slds-p-top_small">                
                <lightning-button name="Save" label="Save" onclick={saveRecord} ></lightning-button>
            </div>
        </div>
    </div>

</template>
 
dynamicAddRow.js

import { LightningElement, track,api } from 'lwc';
import ACCOUNT_OBJECT from '@salesforce/schema/Account';
import NAME_FIELD from '@salesforce/schema/Account.Name';
import ACCOUNTNUMBER_FIELD from '@salesforce/schema/Account.AccountNumber';
import PHONE_FIELD from '@salesforce/schema/Account.Phone';
import saveAccounts from '@salesforce/apex/AccountController.saveAccounts';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
export default class CreateDynamicRecord extends LightningElement {
    @track accountList = []; 
    @track index = 0;
    @api recordId;
    @track name = NAME_FIELD;
    @track industry = ACCOUNTNUMBER_FIELD;
    @track phone = PHONE_FIELD;

    @api record = {
        firstName : '',
        lastName : '',
        Email : '',
        Phone : '',
        Title : ''
    }

    addRow(){

        this.index++;
   
        this.accountList.push ({
            sobjectType: 'Account',
            Name: '',
            AccountNumber : '',
            Phone: ''
        });

        console.log('Enter ',this.accountList);
        
       // this.accountList.push(this.record);
        //console.log(' After adding Record List ', this.accountList);
    }
    
    removeRow(){

        var index = this.index;
      
        if(this.accountList.length>1)
           this.accountList.splice(index, 1);

        //this.dispatchEvent(new CustomEvent('deleterow', {detail: this.index}));
        //console.log(' After adding Record List ', this.dispatchEvent);
    } 

    acc = {
        Name : this.name,
        AccountNumber : this.accNumber,
        Phone : this.phone
    }

    handleNameChange(event) {
        this.acc.Name = event.target.value;
        console.log("name", this.acc.Name);
    }
    
    handleAccountNumberChange(event) {
        this.acc.AccountNumber = event.target.value;
        console.log("AccountNumber", this.acc.AccountNumber);
    }
    
    handlePhoneChange(event) {
        this.acc.Phone = event.target.value;
        console.log("Phone", this.acc.Phone);
    }
    
    saveRecord(){        
        saveAccounts(this.acc.accountList)
            .then(result => {
                this.message = result;
                this.error = undefined;
                if(this.message !== undefined) {
                    this.acc.Name = '';
                    this.acc.AccountNumber = '';
                    this.acc.Phone = '';
                    this.dispatchEvent(
                        new ShowToastEvent({
                            title: 'Success',
                            message: 'Account created successfully',
                            variant: 'success',
                        }),
                    );
                }
                
                console.log(JSON.stringify(result));
                console.log("result", this.message);
                /*console.log(' After adding Record List ', result);
                this.accountList = result;
                console.log(' After adding Record List ', this.accountList);*/
            })
            .catch(error => {
                this.message = undefined;
                this.error = error;
                this.dispatchEvent(
                    new ShowToastEvent({
                        title: 'Error creating record',
                        message: error.body.message,
                        variant: 'error',
                    }),
                );
                console.log("error", JSON.stringify(this.error));
            });
    }
      
}
 
AccountController.apex  

public with sharing class AccountController { 
 
    @AuraEnabled( cacheable = true ) 
    public static List< Account > getAccounts() { 
      
        return [ SELECT Id, Name, Industry FROM Account LIMIT 10 ]; 
         
    } 
     
    @AuraEnabled( cacheable = true )
    public static void saveAccounts(List<Account> accList){
        Insert accList;
        /*if(accList.size()>0 && accList != null){
            insert accList;
        }*/
    } 
}
Thanks 
Siva
 
The user does not see the contact when adding the ContactShare

Code in Trigger:
User user = [SELECT Id FROM User WHERE Alias = 'mmana']; Contact contact = [SELECT Id FROM Contact LIMIT 1]; ContactShare contactShare = new ContactShare();
contactShare.Contact = contact;
contactShare.ContactId = contact.Id;
contactShare.UserOrGroupId = user.Id; contactShare.ContactAccessLevel = 'Edit';
insert contactShare;

Organization-Wide Defaults
Account: Private
Contact: Private

How can i solve this problem with Apex?
Hi All

I have a problem at the moment where i am trying to access a variable in the controller which i am creating in APEX but i cannot pull it through. Any suggestions would be great!

APEX
@AuraEnabled
    public static Senior_Parking_Permit__c checkPermit(String permitNumber){
        system.debug('Hit the server');
        system.debug(permitNumber);
        
        User currUser = getCurrPortalUser();
        system.debug('currUser =  ' + currUser );
         
        if (currUser.ContactId == null ) return null;
        
        List<Senior_Parking_Permit__c> foundPermits = [SELECT Id, Name, Permit_Number__c, Claimed__c FROM Senior_Parking_Permit__c 
                                                               WHERE Permit_Number__c = :permitNumber
                                                               LIMIT 1];
        
        if(foundPermits.size() == 0) {
            system.debug('Could not find any matching Senior_Parking_Permit__c rec, do nothing ');
            
            return null;
        }
        else{
            Senior_Parking_Permit__c foundPermit = foundPermits[0];
            
            if(foundPermit.Claimed__c == true){
                
                Boolean Claimed = true;
            }
            else {
                Boolean Claimed = false;
            }
            
            system.debug('Found a Senior_Parking_Permit__c record - ' + foundPermit);
            system.debug('... and it hasnt been claimed yet, lets claim it. ');
            
            foundPermit.Claimed__c = true;
            system.debug('Before update foundPermit  - ' + foundPermit);
            
            update foundPermit;
            return foundPermit;
        }
    }

Controller
permitClaim : function(component, event, helper){
        var action = component.get("c.checkPermit");
        var permitNumber = component.get("v.simpleNewCase.Permit_Number__c");
        
        console.log("permitNumber",permitNumber);
        
        action.setParams({
            permitNumber : permitNumber
        });
        
        action.setCallback(this, function(a) {
            
            var state = a.getState();
            console.log("State",state);
            var permitData = a.getReturnValue(); 
            console.log("permitData",permitData);
            
            if(permitData === null){
                debugger;
                var permitNotFound = true;
                component.set("v.permitNotFound",true);
                console.log(permitNotFound);
            }
            
            if(a.getState() === 'SUCCESS'){
                
                if(permitData != null){
                    debugger;
                component.set("v.foundPermit",permitData.Permit_Number__c);
                component.set("v.permitClaimed",permitData.Claimed);
                    
                var permitFound = component.get("v.foundPermit");
                console.log("permitNumber",permitNumber);
                    
                var permitClaimed = component.get("v.permitClaimed");
                console.log("permitClaimed",permitClaimed);
                    
                var permitNotFound = false;
                component.set("v.permitNotFound",false);
                console.log(permitNotFound);
                    
                }
                
                if((permitFound == permitNumber) && (permitClaimed === false)){
                    var showToast = $A.get("e.force:showToast");
                    console.log("showToast")
                    showToast.setParams({
                        "title": "Permit Found",
                        "type" :"Success",
                        "message": "Your existing parking permit has been found."
                    });
                    showToast.fire();
                } else if ((permitFound == permitNumber) && (permitClaimed === true)){
                    
                    var showToast = $A.get("e.force:showToast");
                    console.log("showToast")
                    showToast.setParams({
                        "title": "Permit Already Claimed",
                        "type" :"error",
                        "message": "The parking permit number you have selected has already been claimed. If this has been claimed incorrectly, please contact Customer Services."
                    });
                    showToast.fire();
                } else if(permitNotFound === true){
                    var showToast = $A.get("e.force:showToast");
                    console.log("showToast")
                    showToast.setParams({
                        "title": "Permit Not Found",
                        "type" :"error",
                        "message": "The parking permit number you have entered has not been recognised. Please try again."
                    });
                    showToast.fire();
                }
            }
            
        });
        $A.enqueueAction(action);
    }
I am trying to get the attribute 'Claimed' to appear with a simple true or false but cant get it to work. 

Thanks for your help!

Tom 
 
    for (User use : Trigger.new) {
        String accid = use.AccountId;
        List<Account> account = [SELECT AccountNumber FROM Account WHERE Primary_Id__c = :accid];
        if(account != null && account.size()>0)
             use.Primary_id__c = account[0].AccountNumber;
    }
}

I have one object which has one field of checkbox type now my requirement is that at a time only one record in the object can have checkbox value as true so suppose If I save a record with checkbox value as true and then I create another record and trying to save record with checkbox as true so in this case validation rule should throw error.

thanks in advance

hi I have lightning flow which call apex and perform some logic and then apex returns the list of records which I need to display in lightning component in the lightning flow 

please suggest how can I do this 

thanks

I have three inputs in the flow screen and I am calling invocable apex from the flow since invocable apex accept only one input parameter so can you  please suggest me how can I sent my all three inputs to the apex as list of string so that there I can use them accordingly

Thanks in advance

[  
   {  
      "Id":"a0F7F000006lv7OUAQ",
      "Name":"Lightning Arrester(ESE Type (50 m -3 Nos , 65m - 3 Nos , 100 m - 6 Nos , 107 m -",
      "Price__c":2998,
      "Stage__c":"Civil Works",
      "Quantity__c":"43"
   },
   {  
      "Id":"a0F7F000006lv7EUAQ",
      "Name":"Safety Lifelines",
      "Price__c":20,
      "Stage__c":"Civil Works",
      "Quantity__c":"45"
   }
]

i have records of custom object with apiname productRenew__c in json string formate and i want to convert this json to corresponding object so that i can save the records to the db

Please Help
Thanks in advance
  • September 08, 2018
  • Like
  • 0
<table id="myDummyTable" class="slds-table slds-table--bordered  tablesorter">
                                <thead>
                                    <tr class="slds-text-title--caps headerRow">
                                        <apex:repeat value="{! headerList }" var="headerVar" id="theaddrs"  >                          
                                            <th scope="col" >
                                                {!headerVar}                                                                                       
                                            </th>
                                        </apex:repeat>                            
                                    </tr>
                                </thead> 
                                <tbody>  
                                    <apex:variable var="count" value="{!1}"/>
                                    
                                        <apex:repeat value="{! sObjectList }" var="ct"  >  
                                            <tr id="tr1">
                                                
                                                    <apex:repeat value="{!fieldList}" var="fieldVar">
                                                        <td>  
                                                            <div id = "td1">
                                                                <apex:outputField  value="{!ct[fieldVar]}"  />                                                                                                   
                                                            </div>
                                                            <div id = "td2">
                                                                <apex:inputField  value="{!ct[fieldVar]}"  />
                                                            </div>
                                                        </td>                                           
                                                        <apex:variable value="{!count+1}" var="count"/> 
                                                    </apex:repeat> 
                                               
                                               
                                            </tr> 
                                        </apex:repeat> 
                                  
                                    
                                </tbody>                                                           
                            </table>
table data should be display as read only but whenever i click on particular td that td should become editable i am doing this by add and remove class but it is applying only on my first td of my table
.hideClass{
            display:none;
            }   
.showClass{
            display:block;
            }

j$('#td2').addClass('hideClass');
            j$('#td1').dblclick(function(){
                alert("in dblclick");
                j$('#td1').addClass('hideClass');
                j$('#td2').removeClass('hideClass');
            });

Please suggest changes that should i do 
Thanks
 
Hi all,

Here is my code though its not showing any error but I am certain there is someting wrong with it. As it is not fulfilling the requirement.
Please help me rectifying it. and let me know where I am goung wrong.

public class Move_Contact {
    public static void updateContact(List <Contact> conList){
        String MainDomain = '';
        string website ='www' +MainDomain;
                string httpWebsite ='http://www' + MainDomain;
                string httpswebsite ='https://www'+ MainDomain;
                string international = MainDomain + '.%';
        for(Contact myCon : conList){
            if(myCon.Email != null){
                string domain = myCon.Email.split('@').get(1);
                MainDomain = domain;
            }}
                Map <Id,Id> conMap = new Map <Id,Id>();
        for(Contact myCon : conList){
            conMap.put(myCon.Id , mycon.AccountId);
        }
        
                List<Account> acc = [SELECT Id
                                     FROM Account 
                                     WHERE Website =:website
                                     or Website =:httpWebsite
                                     or Website =:httpswebsite
                                     or Website =:international];
                if(acc.size() == 1){
                    For(Contact c : conList){
                        acc.get(0).Id = conMap.get(c.Id);
                        c.AccountId = conMap.get(c.Id);
                    }
                }     
    }

}
at the last page and than select next button a message displays(NO RELATED CONTACTS FOR THIS ACCOUNT).after that when i select again a radio button for account contact will not display only message displays but i have contacts for the account.in search process i have 4-5 same accounr but contacts are different

<apex:page controller="SearchRecords" showHeader="true" >
    <apex:form id="frm">
        <!----<apex:actionFunction name="showcon" action="{!showContact}" reRender="frm" /> --->
        <apex:pageblock >
            <apex:pageBlockSection title="Search Account Records" columns="1">
                Enter Name<apex:inputText value="{!getstring}" id="theTextInput"/>
                <apex:commandButton action="{!searchRecords}" value="Search" id="theSearch" reRender="frm"/>
            </apex:pageBlockSection>
            
            <apex:pageBlockSection title="Account Detail" id="pb">
                <apex:pageBlocktable value="{!accountlist}" var="acc">
                    <apex:column >
                        <input type="radio" name="group1" reRender="{!display}" />
                        <apex:actionSupport event="onclick" action="{!showContact}" reRender="conSection"  >
                            <apex:param assignTo="{!AccId}" name="accname" value="{!acc.id}"/>
                        </apex:actionSupport>
                    </apex:column>
                    <apex:column value="{!acc.Name}"/>
                    <apex:column value="{!acc.Phone}" />
                </apex:pageBlocktable>
            </apex:pageBlockSection>
            
            <apex:outputPanel id="conSection">
                <apex:pageBlockSection title="Related Contact" id="conpgblk" rendered="{!display}" >
                    <apex:outputPanel rendered="{!listWrapper.size == 0}">
                        <b> NO RELATED CONTACTS FOR THIS ACCOUNT.</b> 
                    </apex:outputPanel> 
                    
                    <apex:outputPanel rendered="{!listWrapper.size != 0}">
                        <div align="center" draggable="false" >
                            <apex:commandButton value="Send Email" action="{!SendEmail}" />
                            <apex:commandButton value="Print Detail" action="{!PrintDetail}"/>
                        </div>
                        <apex:pageBlockTable value="{!listWrapper}" id="pbt1" var="wrap">
                            <apex:column headerValue="Select">
                            <apex:inputCheckbox value="{!wrap.checked}" id="inputBox"/>
                            </apex:column>
                            <apex:column value="{!wrap.con.Name}"/>
                            <apex:column value="{!wrap.con.Phone}"/>
                            <apex:column value="{!wrap.con.Email}"/>
                            <apex:column value="{!wrap.con.Account.Name}"/>
                            <apex:column value="{!wrap.con.AccountId}"/>
                            <apex:column value="{!wrap.con.Id}"/>
                        </apex:pageBlockTable>
                    <apex:commandButton value="First Page" rerender="conpgblk" action="{!FirstPage}" disabled="{!prev}"/>
                    <apex:commandButton value="Previous" rerender="conpgblk" action="{!previous}" disabled="{!prev}"/>
                    <apex:commandButton value="Next" rerender="conpgblk" action="{!next}" disabled=""/>
                    <apex:commandButton value="Last Page" rerender="conpgblk" action="{!LastPage}" disabled=""/> 
                    </apex:outputPanel>
                </apex:pageBlockSection>
            </apex:outputPanel>
        </apex:pageblock>
    </apex:form>
</apex:page>

public class SearchRecords {
    public boolean display{get;set;}
    public String AccId{get;set;}
    public string getstring{get;set;}
    public List<Account> accountlist {get;set;}
    public list<Contact> conList{get;set;}
    private integer totalRecs = 0;
    private integer OffsetSize = 0;
    private integer LimitSize=6;
    public void searchRecords(){
        
        display=false;
        accountlist= new list<Account>();
        if(getstring!=null){
            accountlist= Database.query('select id,AccountNumber,name,Phone from Account where name like \'%'+getstring+'%\'');
        }
    } 
    
   public List<WrapperClass> listWrapper {get;set;}
    
    public void showContact(){
       
        display=true;
        listWrapper = new List<WrapperClass>();
        List<Contact> conlist =[SELECT id,Title,Fax,Birthdate,Name,Account.Name,Phone,Email FROM Contact WHERE AccountId=:AccId LIMIT :LimitSize OFFSET :OffsetSize];
        if(conlist!=NULL){
            totalRecs = conlist.size();
            for(contact con:conlist)
            {
                listWrapper.add(new WrapperClass(con));
            }
        }
    }
    public class WrapperClass {
        public boolean fgjj;
        public Boolean checked {get;set;}
        public contact con {get;set;}
        public WrapperClass(contact con) {
            this.con=con;
            checked=false;
        }
    }
    public pageReference SendEmail(){
        return null;
    }
    public pageReference PrintDetail(){
        return new pageReference('apex/PrintContactDetail');
    }
    public void FirstPage(){
        OffsetSize = 0;
        showContact();
    }
    public void previous(){
        OffsetSize = OffsetSize - LimitSize;
        showContact();
    }
    public void next(){
        OffsetSize = OffsetSize + LimitSize;
        System.debug('>>>>>OffsetSize '+OffsetSize);
        showContact();
    }
    public void LastPage(){
        OffsetSize = totalrecs - math.mod(totalRecs,LimitSize);
        system.debug('====>OffsetSize'+OffsetSize);
        showContact();
    }
    public boolean getprev(){
        if(OffsetSize == 0)
            return true;
        else
            return false;
        
    }
    public boolean getnxt(){
        if((OffsetSize + LimitSize) > totalRecs)
            return true;
        else
            return false;
    }
}
select id,createddate from someObject

and my query is returing list of sObjects with its data and Createddate
and then i am assigning this list of sobject to my attribute of lightning component like this
var action = component.get("c.getResponseHistory");
        action.setCallback(this, function(response) {
            var state = response.getState();
            if (state === "SUCCESS") {  
                component.set("v.responseObject",response.getReturnValue());
                             
            }
         });
        $A.enqueueAction(action);
for each record i dont want to assign full datetime as createddate return datetime i want createddate to be converted to only date for each record

Please help me to do this 
Thanks
 
Hi,

I have the following trigger:
trigger conCreateFromAccount on Account (after insert) {
  List<Contact> conList = new List<Contact>();
      for (Account newAccount: Trigger.New) {

           Contact con = new Contact();
           con.lastname = newAccount.name + '  - Contact';
           con.Accountid = newAccount.id;
           conList.add(con);
          }
          
    insert conList;
    list<account>acctsUp = new list<account>();
    for(contact e: conList){

         account a = new account(Id = e.AccountId);
         a.Contact_ID__c = e.Id;
         acctsUp.add(a);
      }

      update acctsUp;
}

From what I know, records in AFTER are read-only and cannot be updated. However, I am able to update the account record in the after insert trigger without any issue. Theoretically I should be receiving the Read Only error, but I am not. Why?
 
Hello,

I have a List of Objects, for example:

myList = (Object1, Object2 , Object3, Object4)

where:
Object1.Name = 'NameA',
Object2.Name = 'NameB',
Object3.Name = 'NameA' and
Object4.Name='NameC'

I have to create a List of Names without repeated Names, and also I need a List that counts the number of the elements, in this example:

NonRepeatedNamesList = ('NameA','NameB','NameC');
CounterList = (2,1,1);

Can anybody help me please?




 
I installed Developer Hub Trial Org 64-bit Windows option.
I created a trial project with: 
     sfdx force:project:create -n geolocation

But, when I try to create the scratch org with:
      sfdx force:org:create -s -f config/project-scratch-def.json -a GeoAppScratch
I get this:
     ERROR running force:org:create: You do  not have access to the [scratchorgiinfo] object

I've tried several suggested fixes that I found when I searched for the above error. None has resolved the issue for me.

I have created a class implementing Schedulable and have created a batch job to run at 9 pm every day. The job is available at Setup-> Monitoring -> Scheduled Jobs. I have added System.Debug statements in my class for traceability purpose in case of any issues. But I am unable to figure a way to get/mail the debug logs for the same. Can you please let me know what Setting should be set in order to get the debug logs for the Scheduled Jobs?

  • February 08, 2012
  • Like
  • 2