• Surya G
  • NEWBIE
  • 425 Points
  • Member since 2019

  • Chatter
    Feed
  • 13
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 53
    Replies
I have a String value from a Long Text field that contains Name/Email values. I need to extract only the names separated by a semi colon when there are multiple entries (no semi colon in the text if only one name) using Apex/String methods into another variable. Essentially strip out anything that begins with the pipe delimiter ' | ' and ends with '.com' (will always end in '.com').

Single value scenario: 
John Test | jtest@none.com

Expected:
John Test

Multiple values:
Scott Rogers | srogers@none.com; Mike Smith | msmith@none.com; Matt White | mwhite@none.com

Expected:
Scott Rogers; Mike Smith; Matt White

I've tried using substring/left/right but my approach may not be correct as I'm getting a null value each time and I also believe I need an array/list to grab each entry if multiple matches.

Example of test:
s1 = 'Scott Rogers | srogers@none.com; Mike Smith | msmith@none.com; Matt White | mwhite@none.com';

String s2 = s1.right(1).substringBetween(' |','.com');
Hi Team,

I am trying to create a validation Rule i have custom Field called status it has 4 picklist values(NEW,old,current,upgraded) when any one of the value is selected user shou;ld not be able to edit the Fields.


AND(
    ISPICKVAL( status__c,'NEW'),
    OR(
        ISCHANGED( NHPMS__Re_Admit__c ),
        ISCHANGED( NHPMS__Discharge_Date__c ),
        ISCHANGED( Next_Appointment__c )
)
    ISPICKVAL( status__c,'old'),
    OR(
        ISCHANGED( NHPMS__Re_Admit__c ),
        ISCHANGED( NHPMS__Discharge_Date__c ),
        ISCHANGED( Next_Appointment__c ))
    )
    ISPICKVAL( status__c,'current'),
    OR(
        ISCHANGED( NHPMS__Re_Admit__c ),
        ISCHANGED( NHPMS__Discharge_Date__c ),
        ISCHANGED( Next_Appointment__c ))
    
)
    ISPICKVAL( status__c,'upgraded'),
    OR(
        ISCHANGED( NHPMS__Re_Admit__c ),
        ISCHANGED( NHPMS__Discharge_Date__c ),
        ISCHANGED( Next_Appointment__c ))
    
)
)
Dear gurus,

I have a problem where 

GIVEN there is a string of characters, and i need to ivoke a reverse method is invoked such that it returns an array of characters in reversed order for alphanumeric characters only however all other non-alphanumeric characters need to retain their original position -
How to Implement solution in Apex?

I tried below code but no luck
public class assessment {
  public static List<String> reverseSpecialString(String input) {
        List<String> resultList = new List<String>();
         // IMPLEMENT
        resultList = input.split('');
        string reversedString='';
        for(integer i=resultList.size()-1;i>=0;i--)
            {
             
            reversedString=reversedString+resultList[i];
               
            }
    
       
        
        
         return resultList;
      
       }
    
    public static void validateSolution() {
        String input = 'ABC@HI#J2';
        List<String> expected = new List<String> {'2','J','I','@','H','C','#','B','A'};
        List<String> actual = reverseSpecialString(input);
        
        System.assertEquals(expected, actual, 'Invalid Results');
    }
}

Thanks,
Fiona​​​​​​​

 
hello Peers,
I am stuck in a requirement. My requirement is that when any record is update from detail page then my lwc will  call.
lwc is also on detail page.
If it were in aura, we could use force:recordData but in lwc it not works.

please anybody suggest me what should I do.
it's urgent for me.
Thank in advance
Hi All,

I was asked this Q in one of the interviews. Eliminate all duplicate values from a string. For Eg. I/P = 'THEMISSISSIPPI'
O/P = 'THEM' (all other values are truncated because they are duplicates)
Can you please help. Appreciate your response.

Thanks.
I am looking for a solution to show when a community user updates certain fields on a record. Ideally it would act similar to the last modified field but only when a user updates certain fields.
 
Is there a formula field I should use? if so what would the formula look like?
I have a basic coding about getObjectInfos adapter but it seems not working:
import { LightningElement, wire } from 'lwc';
import { getObjectInfos } from 'lightning/uiObjectInfoApi';
import ACCOUNT_OBJECT from '@salesforce/schema/Account';
import OPPORTUNITY_OBJECT from '@salesforce/schema/Opportunity';


export default class GetObjectInfosLwc extends LightningElement {
    @wire(getObjectInfos, {objectApiName:[ACCOUNT_OBJECT, OPPORTUNITY_OBJECT]})
    objectInfosHandler({data, error}) {
        if(data) {
            console.log("Get Multiple " + data)
        }
        if(error) {
            console.error(error)
        }
    }
}
and here is the Browser Console log:
beaconLib.BeaconLibrary.js:37 {InstrumentationResult :  ( RECEIVED = 14 , SUCCESS -> LOG = 14 , Topic = AILTN )  , TracingResponse : ( AsyncResults ) , TelemetryResponse : ( AsyncResults ): {…}}
As you can see, it doesn't print the list of metadata (for Account and Opportunity). I need some help!
Thank you so much.




 
Hello, I have a before delete Trigger on Content Version. A user here told me that there is a limitation that does not allow before delete triggers to work on content version. Do you know a possibility how to overcome this problem?
The trigger code is:

trigger ContentVersionTrigger on ContentVersion (before delete) { Set<Id> contentDocumentIdSet = new Set<Id>();

if(trigger.IsDelete){ for(ContentVersion con : Trigger.old){

if(con.ContentDocumentId != null) { contentDocumentIdSet.add(con.ContentDocumentId); } } ContentDocumentLink cdl = [SELECT ContentDocumentId,

LinkedEntityId FROM ContentDocumentLink WHERE ContentDocumentId IN:contentDocumentIdSet Limit 1];

for(ContentVersion con : Trigger.old){

if(con.Dokumentenklasse__c =='Geschäftsbrief'){
if(cdl!=null){

con.addError('You cant delete the file');
}
}
}
}
}
Hi, 

Create an account with name 'test account' & create a field on account - > number of contacts. Write a trigger such that when whenever a new contact is created it is automatically added to 'test account'.

Please help me writing this trigger. I have written the following code. Pls tell me where am I going wrong.
Thanks

trigger InsertContact1 on Contact (after insert) {
      
    Account acList = [Select id, Name from Account where Name = 'Test Account'];
    List<Contact> contList = new List<contact>();
    
    for(Contact c: trigger.new){
        contList.add(c);
    }    insert contList;
    
    if(contList.size()>0){
        for(Contact c: contList){
            c.AccountId = acList.id;
            acList.Number_Of_Contacts__c = integer.valueOf(contList.size());
    }
    }
}
Components:--

<aura:component controller="Staffbutton" implements="lightning:availableForFlowActions, force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" >
       
    <aura:attribute name="Staffbutton" type="string"/>
    <aura:attribute name="StaffdId" type="String"/>  
<lightning:button label="Success" variant="brand"
         onclick="{!c.displaymsg}"/>
    </div>
</aura:component>

Controller:-
displaymsg: function (component, event, helper) {
         var toastEvent = $A.get("e.force:showToast");
            //fire the toast event in Salesforce app and Lightning Experience
            toastEvent.setParams({
                "title": "Success!",
                "type": "success",
                "mode": 'dismissable',
                "message": "The component successfully load."+component.get('v.recordId')
            });
            toastEvent.fire();
    
    
            }})



I'm not unable display record Id with toast message.

I'm getting this one..User-added image
Hello guys, 
Is there any ways to pass parameter in designe attribute of Lightning component.
My Requirement -  In community builder, when drag the component. In component setting window, I need following things,
1. Select sObject using picklist (already done).
2. On the basis of selected object, In want get the fieldset name in second picklist.
So, anyone can help me to achieve 2 point through design attribute.
Thanks 
Hello,

I having an issue creating a record using createRecord.  The error details in the console shows REQUIRED_FIELD_MISSING. I don't quite understand because I am passing in the two required fields in the recordInput property when createRecord method is being called. I verify this when I use stringify to see the content of the recordInput prior to the createRecord method call in the next statement. But when it's called immediately this error is thrown that shows the REQUIRED_FIELD_MISSING. See two console logs:

apiAccountRecoveryHelper.createAccountRecovery.recordInput = {"apiName":"Account_Recovery__c","theRecord":{"Platform_Change__c":"a1u18000000cu*****","Account_Name__c":"00118000011im*****","Launch__c":"a3l18000000AL*****"}}

apiAccountRecoveryHelper.createAccountRecovery.createRecord.error = {"status":400,"body":{"message":"An error occurred while trying to update the record. Please try again.","statusCode":400,"enhancedErrorType":"RecordError","output":{"errors":[],"fieldErrors":{"Account_Name__c":[{"constituentField":null,"duplicateRecordError":null,"errorCode":"REQUIRED_FIELD_MISSING","field":"Account_Name_c","fieldLabel":"Account Name","message":"Required fields are missing: [Platform_Change__c, Account_Name__c]"}],"Platform_Change__c":[{"constituentField":null,"duplicateRecordError":null,"errorCode":"REQUIRED_FIELD_MISSING","field":"Platform_Change__c","fieldLabel":"Platform Change","message":"Required fields are missing: [Platform_Change__c, Account_Name__c]"}]}}},"headers":{}}

 It's obvious that I'm missing something but can't figure out what it is. I've considered using generateRecordInputForCreate and getRecordCreateDefaults but not real sure why I should. Seems to me that createRecord should work. Any help is much appreciated. 
Hi, I'm trying to learn so decided to write a trigger that pre-populated the SLA field when an account was created, and also created an opportunity with pre-populated fields.

I have managed to either:
Create an account WITHOUT the pre-populated SLA field and WITH an associated opportunity,
OR
Create an account WITH the pre-populated SLA field and create an opportunity that is NOT associated with the account.

I can't work out how to combine the two, can anyone help please?

This is my code:

This version creates both correctly, but excludes the auto completion of the SLA field (used After insert as Before causes read only error):

trigger NewAccountOppTEST on Account (After insert) {

    List<Opportunity> OppList = new List<Opportunity>();
    
    //Auto populate SLA field for new account
    for (account acc : Trigger.new ){ 
                   
{
    //Create opportunity
    Opportunity opp = new Opportunity();
    opp.name        = 'Auto Created again';
    opp.CloseDate   = Date.today()+7;
    opp.Stagename   = 'Prospecting';
    opp.AccountID   = acc.id;  
    OppList.add(opp);

Insert OppList;
}
}


This version creates everything but the opportunity is orphaned:

trigger NewAccountOppTEST on Account (Before insert, after update) {

    List<Opportunity> OppList = new List<Opportunity>();
    
    //Auto populate SLA field for new account
    for (account acc : Trigger.new ){ 
        acc.SLA__c  = 'Gold';            
{
    //Create opportunity
    Opportunity opp = new Opportunity();
    opp.name        = 'Auto Created again';
    opp.CloseDate   = Date.today()+7;
    opp.Stagename   = 'Prospecting';
    opp.AccountID   = acc.id;  
    OppList.add(opp);

Insert OppList;
}
}
I have a String value from a Long Text field that contains Name/Email values. I need to extract only the names separated by a semi colon when there are multiple entries (no semi colon in the text if only one name) using Apex/String methods into another variable. Essentially strip out anything that begins with the pipe delimiter ' | ' and ends with '.com' (will always end in '.com').

Single value scenario: 
John Test | jtest@none.com

Expected:
John Test

Multiple values:
Scott Rogers | srogers@none.com; Mike Smith | msmith@none.com; Matt White | mwhite@none.com

Expected:
Scott Rogers; Mike Smith; Matt White

I've tried using substring/left/right but my approach may not be correct as I'm getting a null value each time and I also believe I need an array/list to grab each entry if multiple matches.

Example of test:
s1 = 'Scott Rogers | srogers@none.com; Mike Smith | msmith@none.com; Matt White | mwhite@none.com';

String s2 = s1.right(1).substringBetween(' |','.com');
I have requirement of creating a LWC in which i have 8 fields from 2 different Objects. After user has entered the data, on click of 1 button, records should be saved in respective objects. 
Basically is there any way to save records of multiple objects with a single save button? 
I know how to create record in LWC using Apex, using Lightning/UI RecordApi and lightning-record-edit-form,  But all of these to save records in a single object with one button click.
please help me out.
hy Experts,
I'm stuck in weird error. In calling a apex method from anonymous window,it's working fine but when i call it from js it's throwing error like this [Status=Unauthorized, StatusCode=401] .
I'm  little confused what's the main issue.
can somebody help me to solving it and tell me cause why it's throwing error.
I.m passing listViewId and getting listView Records.
Below is my Code
@AuraEnabled(cacheable = true)
    public static void getListviewFilters(String filterId) {
        HttpRequest req = new HttpRequest();
	    String baseUrl = URL.getSalesforceBaseUrl().toExternalForm();
        
	    String endPoinURL = baseUrl+'/services/data/v52.0/sobjects/Account/listviews/'+ filterId +'/describe';
	    req.setEndpoint(endPoinURL);
	    req.setMethod('GET');
        req.setHeader('Authorization', 'Bearer ' + UserInfo.getSessionId());
        
	       Http http = new Http();
	       HttpResponse response = http.send(req);
        system.debug('response : ' + response);
		
	if( response.getStatusCode() == 200 ) {
		Map<String, Object> tokenResponse = (Map<String, Object>) JSON.deserializeUntyped(response.getBody());
		String query = (String) tokenResponse.get('query');
		System.debug(query);
        List<Account> AccountList = new List<Account>();
        for(Account accountObj : database.query(query)){
		AccountList.add(accountObj);
		system.debug('accountObj : ' + accountObj);
        }
    	system.debug(AccountList.size());
        
	}
	}

Below is my Js Code
<aura:component controller="ListViewNewVersionInLwcCtrl">
    <aura:attribute name="firstName" type="String" default="world"/>
    <lightning:button label="Call server" onclick="{!c.echo}"/>
</aura:component>


--------------------------------------------------------------------------------------

({
    "echo" : function(cmp) {
        var action = cmp.get("c.getListviewFilters1");
        action.setParams({ filterId : '00B5g000002WfNSEA0' });
        action.setCallback(this, function(response) {
            var state = response.getState();
            alert(state);
            if (state === "SUCCESS") {
                alert("From server: " + response.getReturnValue());
       }
            else if (state === "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);
    }
})

Thanks In advance
Hi Team,

I am trying to create a validation Rule i have custom Field called status it has 4 picklist values(NEW,old,current,upgraded) when any one of the value is selected user shou;ld not be able to edit the Fields.


AND(
    ISPICKVAL( status__c,'NEW'),
    OR(
        ISCHANGED( NHPMS__Re_Admit__c ),
        ISCHANGED( NHPMS__Discharge_Date__c ),
        ISCHANGED( Next_Appointment__c )
)
    ISPICKVAL( status__c,'old'),
    OR(
        ISCHANGED( NHPMS__Re_Admit__c ),
        ISCHANGED( NHPMS__Discharge_Date__c ),
        ISCHANGED( Next_Appointment__c ))
    )
    ISPICKVAL( status__c,'current'),
    OR(
        ISCHANGED( NHPMS__Re_Admit__c ),
        ISCHANGED( NHPMS__Discharge_Date__c ),
        ISCHANGED( Next_Appointment__c ))
    
)
    ISPICKVAL( status__c,'upgraded'),
    OR(
        ISCHANGED( NHPMS__Re_Admit__c ),
        ISCHANGED( NHPMS__Discharge_Date__c ),
        ISCHANGED( Next_Appointment__c ))
    
)
)
Dear gurus,

I have a problem where 

GIVEN there is a string of characters, and i need to ivoke a reverse method is invoked such that it returns an array of characters in reversed order for alphanumeric characters only however all other non-alphanumeric characters need to retain their original position -
How to Implement solution in Apex?

I tried below code but no luck
public class assessment {
  public static List<String> reverseSpecialString(String input) {
        List<String> resultList = new List<String>();
         // IMPLEMENT
        resultList = input.split('');
        string reversedString='';
        for(integer i=resultList.size()-1;i>=0;i--)
            {
             
            reversedString=reversedString+resultList[i];
               
            }
    
       
        
        
         return resultList;
      
       }
    
    public static void validateSolution() {
        String input = 'ABC@HI#J2';
        List<String> expected = new List<String> {'2','J','I','@','H','C','#','B','A'};
        List<String> actual = reverseSpecialString(input);
        
        System.assertEquals(expected, actual, 'Invalid Results');
    }
}

Thanks,
Fiona​​​​​​​

 
I have a requirement to display Accounts-->child Accounts-->Tasks-->Child Tasks in the JSON.

Here is my Apex code:
 
List<Account> accountRecordsList = new list<Account>(); 
List<Custom_Tasks__c> taskRecordsList = new list<Custom_Tasks__c>(); 

accountRecordsList = [SELECT Id,Name,parent_account__c, (SELECT Id, Name FROM Accounts1__r) FROM Account WHERE Id = '<some record id>'];
string strJSON = JSON.serialize(accountRecordsList); //Account and Child Accounts

 Set<Id> accountIds = new Set<Id>();
        for(Account pr : accountRecordsList){
            for(Account cpr : pr.Accounts1__r){
            if(cpr.id != null){
                accountIds.add(cpr.id);
            }
            }
        }
taskRecordsList = [SELECT id, name,account__c, (SELECT id, name,pse__Start_Date__c, pse__End_Date__c from Sub_Tasks1__r ) from Custom_Tasks__c where account__c in :accountIds];
string ptJSON = JSON.serialize(taskRecordsList); //Tasks and Child Tasks related to above obtained child accounts

From the above code,
  • in strJSON, I am getting Accounts and its child accounts data.
  • in ptJSON, I am getting Tasks and Child Tasks related to above Child accounts
Now, is there anyway, I can append ptJSON under its related child Accounts in strJSON. Can anyone please suggest solution on how to get this done.

Thanks! 
  • August 03, 2021
  • Like
  • 0
Hello Developers.
I have a Lwc Component that is on recordPage.I want to old value and new value that is changed when Record is update.
Can anyone suggest me how to achieve it.
Thanks in advance
hi guys, 
i have a question plz:
How can i get a reference to a custom label dynamically using lwc:
i have this code and i want to convert it to lwc:
var currentCat = categoryWrapper.categories[i];  var labelReference = $A.getReference("$Label.c."+currentCat.name);   component.set("v.tempLabel", labelReference);
//we can't use $A.getreference in lwc,
 and using apex i didn't found a solution 
this is the function in apex:
 @AuraEnabled     public static String getLabel(String LabelName){                  system.debug('LabelName'+LabelName);         String s2 = system.Label.LabelName ;  return s2;     }
this is the function in lwc:
 getLabel({
                    LabelName:labelReference, //labelreference is the name of custom label
                }).then(result=>{
                    
                    console.log('myJSON:'+result);
 
                }).catch(error=>{
                    console.log('error');
                })
//i want to return the value of a custom label when i send the name of custom label in parameter. Where Is my error, and is there a solution ?
Best Regards
String input = '{"orgId":{"isRequired":"true", "valiateDataType": "Id"},"numOfVehicles":{"isRequired": "true"}}';
Map<String,object> o = (Map<String,object>) JSON.deserializeUntyped(input);
map<string,Id> mapsOfIds = new map<string,Id>();
mapss.put('orgId','003J000001q24JUIAY');
for(string key : mapOfIds.keyset()){
    map<string,string> mapIter = o.get(key);
}

I have a code as above and i am getting the error Illegal assignment from Object to Map<String,String>  at last line where i am assigning mapIter.

hello Peers,
I am stuck in a requirement. My requirement is that when any record is update from detail page then my lwc will  call.
lwc is also on detail page.
If it were in aura, we could use force:recordData but in lwc it not works.

please anybody suggest me what should I do.
it's urgent for me.
Thank in advance
Hello Friends
In this picture here is the Merge button in Account-Related List in classic
But I want this button on Lightning on the basis of Account-Related
contact how can I do this I have tried the edit the page but it's not showing can you please
​​​​​​​help me to solve these Functionalities.
User-added image
  • August 02, 2021
  • Like
  • 0
Hi All,
I have a requirement to generate SOQL 101 error  in a for loop.
Using for loop,generate 100+ SOQL in one transaction.
Generate 101 error.
Using future function,resolve this issue and perform 150 SOQL in one transaction.
Code below is not compiling.
Pls help!!!!

Apex Class:

public class SOQL101Error {
List<Student_Master__c> studentlist = new List<Student_Master__c>();
    studentlist = [SELECT id,Name,First_Name__c,Last_Name__c FROM Student_Master__c];
    for(Student_Master__c sm: studentlist){
       // string query =' select ID,Name from Account ';
    }

}

 
  • July 27, 2021
  • Like
  • 0
Hi,
I created check box for fullday,Half day and Mixed day. So, I was trying to write this with the help of radio buttons because in check box i can select all three checkboxes at once.
<h1><b>Select Leave</b></h1>
<lightning:input type="checkbox" label="Full Day" name="Full Day" aura:id="apps" value="fullDay" onchange="{! c.handleChange }" />
<lightning:input type="checkbox" label="Half Day" name="Half Day" aura:id="product" value="halfDay" onchange="{! c.handleChange }" />
<lightning:input type="checkbox" label="Mixed Day" name="Mixed Day" aura:id="service" value="mixedDay" onchange="{! c.handleChange }" />

Thanks in advance