• smriti sharan19
  • NEWBIE
  • 45 Points
  • Member since 2018


  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 10
    Questions
  • 32
    Replies
I am trying to convert date in yyyy-mm-dd format but I am getting result in yyyy-dd-mm format.

Initial Value of DateField: 
datetimeinquiry=2019-06-11 00:00:00

Tried newInstance
    convertToStr = DateTime.newInstance(datetimeinquiry.year(),datetimeinquiry.month(),datetimeinquiry.day()+1).format('yyyy-MM-dd'); 
Result:2019-06-11

Tried formatGMT:
    system.debug('formatGMT: '+datetimeinquiry.formatGMT('yyyy-MM-dd'));
Result:2019-06-11
I want to Pass a list named classList to another method within a class
Complete Requirement
Based on field values coming from case object after query, I want to create account and link the accountid to case. I have created two methods.
Method1 to validateCase
Method 2 to create account. 
I have created a List(caseList) at class level, iterated over list in method1(validateCase) and I want to get values of that in method2(createAccount).However, values of list is not coming in method 2. CaseList when debugging in method2 is not showing any result. 
public with sharing class AccountHandler  {
   
     public static List<Case> caseList = new List<Case>();
    
    @auraEnabled
    public static Boolean validateClaim(Map<String, String>claimIdMap, Map<String,String>claimDateMap) {
        Map<String, String> claimIdToClaimDateMap = new Map<String, String>();
        Boolean flag = false;
        DateTime datetimeinquiry;
        String convertToStr;
        String dateStr;
        Date dformat;
        Date d2format;
        
        Set<String> tempList = new Set<String>();
        tempList = claimIdMap.keySet();
        
        for(String s : tempList){
            claimIdToClaimDateMap.put(claimIdMap.get(s), claimDateMap.get(s));
        }
        System.debug('claimIdToClaimDateMap ' + claimIdToClaimDateMap);
        map<String,Date> myMap=new Map<String,Date>(); 
        caseList = [Select CaseNumber,Date_of_Injury__c,Insurer__c FROM Case where CaseNumber IN:claimIdToClaimDateMap.keySet()];
        system.debug('caseList'+caseList);
        for(Case c:caseList)
        { 
            if(c.Date_of_Injury__c!=null){
                date d = c.Date_of_Injury__c;
                myMap.put(c.CaseNumber, c.Date_of_Injury__c);
            }
        }
        for(String s : myMap.keySet()){
            dformat = Date.valueOf(claimIdToClaimDateMap.get(s));
            if(dformat == myMap.get(s)){
                flag = true;
            }else{
                flag = false;
                break;
            }
        }
        
        return flag;
    }

    
    @auraEnabled
    public static Account createAccount(account accrec,List<Case> caseList) {
        List<Case> casesToUpdate = new List<Case>();
        system.debug('inside createaccount');
        system.debug('accrec'+ accrec);
        system.debug('caseList' + caseList);
        try{
            //insert accrec;
            //caselist jo banayi h isme jo account field h usme accrec id update kardo 
            //for each - iterate on c - c.acc = accrec.id;
            //update caseList;
            //user u = createUser(); 
            //
            system.debug('caseList'+caseList);
            for (Case c: caseList) {
                system.debug('c: '+ c);
                c.Insurer__c = accrec.id;
            }
            update caseList;
            
        }
        catch(Exception ex) {
            System.debug('test'+ex.getMessage());
            throw new AuraHandledException(ex.getMessage());
        }
        
        return accrec;
    }
}

 
I have gone through definition of LightningElement but unable to understand it clearly.

Definition
LightningElement is a custom wrapper of the standard HTML element.It extends element to create a JavaScript class for a Lightning web component.
Can we have named export in Lightning Web Component?

In ES6 module there are two ways of exporting module:
Default Export
Named Export
I am able to find deault export in lwc
export default class HelloWorld extends LightningElement {}
But I have not seen named export in LWC so want to know if they are used in lwc?

According to ES6
 There can be several named exports in a ES6 module. A module can export selected components using the syntax given below −
//using multiple export keyword
export component1
export component2
...
...
export componentN


 
Hi I have created a customized lead conversion page  using lightning web component on click of which I want to display standard "Your lead has been converted" popup window. How can I implement this?

User-added image
I am trying to post on twitter using Salesforce but unable to do so. It throws error forbidden. Can someone help me on this.
 
public class twittersalesforceIntegration {
    public Static String getBearerToken() {
    //Encode them
    String keyencoded = EncodingUtil.urlEncode('####', 'UTF-8');
    String secretkeyencoded = EncodingUtil.urlEncode('#####', 'UTF-8');
     
    //Create Final Key String
    String sFinal = keyencoded + ':' + secretkeyencoded;
    //Convert to Blob
    Blob headerValue = Blob.valueOf(sFinal);
     
    //Build Request
    HttpRequest req = new HttpRequest();
    req.setEndpoint('https://api.twitter.com/oauth2/token');
    req.setMethod('POST');
     
    //Add Auth Header
    String authorizationHeader = 'Basic ' + EncodingUtil.base64Encode(headerValue);
    req.setHeader('Authorization', authorizationHeader);
     
    //You need to add this to the request - proved easy to miss in instructions...
    req.setBody('grant_type=client_credentials');
     
    //Make request
    Http http = new Http();
    HTTPResponse res = http.send(req);
    system.debug('res'+res);
    String stoken;
    //Parse JSON for Bearer Token
    JSONParser parser = JSON.createParser(res.getBody());
    while (parser.nextToken() != null) {
    if (parser.getCurrentToken() == JSONToken.FIELD_NAME && parser.getText() == 'access_token'){
    parser.nextToken();
    stoken = parser.getText();
    }
    }
    //Return Token so it can be used in next call
    return stoken;
    }    
    public static void submittotwitter () {
    HttpRequest req2 = new HttpRequest();
    req2.setEndpoint('https://api.twitter.com/1.1/statuses/update.json?status=hello');
    req2.setMethod('POST');     
    //Call Bearer token Method
    String authorizationHeader = 'Bearer ' + getBearerToken();
    req2.setHeader('Authorization', authorizationHeader);
     
    Http http = new Http();
    HTTPResponse res = http.send(req2);
    system.debug('res'+res);  
    }    
}

 
I am deploying a lightning bolt solution and getting error org not allowed to access forcecommunity:embeddedservice.

I have created a new embeddedservice but still getting same error.
Hi,
I have seen multiple links to drag and drop rows in lightning but can we do drag and drop columns in lightning

Example1 of drag and drop rows : https://developer.salesforce.com/forums/?id=9060G0000005OcPQAU

Example2 of drag and drop of rows: https://gist.github.com/brianmfear/fb13ac4781c79fad6495ef7dc1676f4f

Example of drag and drop column and rows but this is not using lightning: https://sindu12jun.github.io/table-dragger/

Has anyone worked on drag and drop of columns in lightning. If yes please share the code.
How to write a trigger when case status is closed then all task should be completed and when all task are completed then case should get closed?
When a opportunity is created then billing address of accounts should get updated into the opportunity?

I have created a custom field on opportunity object BilingAddress__c. Now i want that whenever i create a new opportunity then the billing field on opportunity gets updated with the BillingAddress field of account.

Step 1: Trigger will be created on Opportunity object
Step 2. We will use after insert as it is based on two objects.

Can you give me code for this.
I want to Pass a list named classList to another method within a class
Complete Requirement
Based on field values coming from case object after query, I want to create account and link the accountid to case. I have created two methods.
Method1 to validateCase
Method 2 to create account. 
I have created a List(caseList) at class level, iterated over list in method1(validateCase) and I want to get values of that in method2(createAccount).However, values of list is not coming in method 2. CaseList when debugging in method2 is not showing any result. 
public with sharing class AccountHandler  {
   
     public static List<Case> caseList = new List<Case>();
    
    @auraEnabled
    public static Boolean validateClaim(Map<String, String>claimIdMap, Map<String,String>claimDateMap) {
        Map<String, String> claimIdToClaimDateMap = new Map<String, String>();
        Boolean flag = false;
        DateTime datetimeinquiry;
        String convertToStr;
        String dateStr;
        Date dformat;
        Date d2format;
        
        Set<String> tempList = new Set<String>();
        tempList = claimIdMap.keySet();
        
        for(String s : tempList){
            claimIdToClaimDateMap.put(claimIdMap.get(s), claimDateMap.get(s));
        }
        System.debug('claimIdToClaimDateMap ' + claimIdToClaimDateMap);
        map<String,Date> myMap=new Map<String,Date>(); 
        caseList = [Select CaseNumber,Date_of_Injury__c,Insurer__c FROM Case where CaseNumber IN:claimIdToClaimDateMap.keySet()];
        system.debug('caseList'+caseList);
        for(Case c:caseList)
        { 
            if(c.Date_of_Injury__c!=null){
                date d = c.Date_of_Injury__c;
                myMap.put(c.CaseNumber, c.Date_of_Injury__c);
            }
        }
        for(String s : myMap.keySet()){
            dformat = Date.valueOf(claimIdToClaimDateMap.get(s));
            if(dformat == myMap.get(s)){
                flag = true;
            }else{
                flag = false;
                break;
            }
        }
        
        return flag;
    }

    
    @auraEnabled
    public static Account createAccount(account accrec,List<Case> caseList) {
        List<Case> casesToUpdate = new List<Case>();
        system.debug('inside createaccount');
        system.debug('accrec'+ accrec);
        system.debug('caseList' + caseList);
        try{
            //insert accrec;
            //caselist jo banayi h isme jo account field h usme accrec id update kardo 
            //for each - iterate on c - c.acc = accrec.id;
            //update caseList;
            //user u = createUser(); 
            //
            system.debug('caseList'+caseList);
            for (Case c: caseList) {
                system.debug('c: '+ c);
                c.Insurer__c = accrec.id;
            }
            update caseList;
            
        }
        catch(Exception ex) {
            System.debug('test'+ex.getMessage());
            throw new AuraHandledException(ex.getMessage());
        }
        
        return accrec;
    }
}

 
Create a query and assign the query results to the list
Get this information:
The name of the property
The broker’s email address
How long the property has been on market
(Hint: Use API names, not field names or field labels)
Object: Property

I WANT TO KNOW HOW TO WRITE BELOW QUERY FOR PROPERTY LISTED IN LAST 30 DAYS....

Condition: The property was listed within the last 30 days

public class PropertyUtility {
    public static void newListedProperties(){
        //list<Property__c> newPropList= new List<Property__c>();
        List<Property__c> newPropList=[select name,  broker__r.email__c from Property__c where CreatedDate= LAST_N_DAYS:30];
        //newPropList.add(pro);
        
        for(Property__c p:newPropList){
             String propEmail=  +p.name+ ':' +p.broker__r.email__c;
            system.debug(propEmail);
            
        }
        
    }

}
string propEmail;
   list<property__C> newPropList=[select name,days_on_market__c,broker__r.email__c from property__c where date_listed__c>=LAST_N_DAYS:30];    
                                  system.debug('The list items are........:'+newPropList);
    for(property__C p:newproplist)
     {
         propEmail=p.name+':'+p.broker__r.email__c;
         system.debug('The concatenated string is.....:'+propEmail);
     }
     getting the following error:
Challenge not yet complete in My Trailhead Playground 2
We can’t find the correct SOQL query in the PropertyUtility class.
this is my solution..any corrections let me know..tq
Hello,

Using lightning, I noticed that on Opportunity, if I add some products (OpportunityLineItems), the page will automatically refresh just after.
It is very convenient, because it permits to see the updated Amount field.

In my case, I'm not using OpportunityLineItems but I created a custom object for this need "Custom Line Item".
I have a related list on opportunity, where I can add/delete these items. When I do so, it triggers some Apex and update a field on my opportunity.

My issue is that I need to manually refresh the page to see that the field on opportunity was updated.

I would like to achieve:
  • On my opportunity, I add/edit a "Custom Line Item" directly from the related list
  • A popup opens, I add/edit the line
  • I save, and I'm back to the opportunity page
  • I need to refresh the page to see that the field is well updated by the Trigger. -> How to automatically refresh the page after I add/edit a "Custom line item" from the opportunity page?
Any suggestions?
Hi Experts,
I need to create a trigger on account object which will prevent the users in creating duplicate account based on the name.
Kindly provide me the same.

Regards.
I want to write trigger to enable a checkbox in contact whenever its Account is modified(updated). 
I'm not able to put the condition for Account updated or not! Can you guys provide the logic?? 
 
  • April 12, 2017
  • Like
  • 1
Hi guys,
I have trigger scenario like  when i try to create account if already exists that account name i want to show error message like duplicate account not allowed
can anyone give me a solution for this.if could send me code.
Thanks in Adv 
Hi, Im new to triggers and apex and I need to update phone field (if blank) on contacts from the account field for existing records: 
Here is my try , but Im sure Im missing some elements. Any help is appreciated:

trigger updatephonefield on Contact (after update, after insert ) {
 for (Contact cp : Trigger.new) {
        if ( cp.Phone == null ) {
            cp.Phone == Account.Phone
            }
}
  • August 12, 2016
  • Like
  • 0
Hey guys I'm new to salesforce and I've to update all phone numbers on contact when account phone number changes, how can I do this with trigger? please help.
I have a very basic question. Through Force.com developer console I created a new apex class..say xyz.apxc then I wrote my code and saved my class..now I want to run that class using Developer console.. how I can do that..? Please tell me how can I use System.debug to  execute my class...What will be the steps..?
Guys,

I need to loop through a subquery, but am getting an "Invalid Type: Product_Releases__r" Error.

Query:

IPList = [select Name,(select Account__c, Product_Family__c from Product_Releases_del__r ORDER BY Product_Family__c ASC) from Account a where ParentID =: AccountID];


Loop Code:

    For(Account acc: IPList){
        For(Product_Releases_del__r p: acc.Product_Releases_del__r){
            if( p.Product_Family__c == FTemp){
                acc.remove(p);
            }
            else {
                FTemp = acc.Product_Family__c;
            }   
        }


Thanks
 
Can any one help me writing the trigger for upating the account rating field to 'hot' when the oppty stage is equal to 'closed won'?

thanks in advance...
Hi,
I have an task in which we have to integrate with the intranet ftp server. so we can store and retrive the data files from ftp server.

Does any one have any idea regarding the same. How can we ingrate the salesforce org with ftp server. 

Any  help will be appreciated. 

Thanks to all in advance :)


Hi,

    I want to insert a date through apex code,how can i mention the date data type in apex.. 


Training__c obj=new Training__C();
obj.name='T50';
insert obj;
batch__C b=new batch__C();
b.training__c = obj.id;
b.End_Date__c = 
b.Start_Date__c = 

insert b; 

Good day, 

 

If i have following query :

 

 

Select a.Name , (Select userId From AccountTeamMembers WHERE TeamMemberRole='Sales') From Account a where id='0013000000H0EMSS'

 

 

How can i get the userId ?

 

Thanks in advance !