• Malni Chandrasekaran 2
  • SMARTIE
  • 600 Points
  • Member since 2016

  • Chatter
    Feed
  • 20
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 125
    Replies
Hi , I am struck up in below Trailhead challange and could not understand what wrong in my code.
Please help 

Thanks in advance 

Simulate a SOQL Injection Attack

For this challenge, perform a SOQL injection on the search box to see information that is unintentionally exposed. Navigate to the SOQL Injection Challenge tab within the SOQL Injection application. You will see a search tool for the supply__c object. Use the search box to perform a SOQL injection which returns supplies meant for Nobles only. Hint: If you’ve done this successfully, your query should return one result containing Venison.

SOQL_Injection_Challenge:

public class SOQL_Injection_Challenge {

    public string textual {get; set;}
    public List<Supply__c> whereclause_records {get; set;}



//SELECT Id,Name,Quantity__c,Storage_Location__c,Type__c FROM Supply__c
    public PageReference whereclause_search(){
        string query = 'SELECT Id,Name,Quantity__c,Storage_Location__c,Storage_Location__r.Castle__c,Type__c FROM Supply__c';
        string whereClause = '';

        if(textual != null && textual!=''){
                whereClause += 'name like  \'%'+textual+'%\' ';
        }

        if(whereClause != ''){
            whereclause_records = database.query(query+' where '+whereClause+' Limit 10');
            validate(whereClause,whereclause_records.size());
        }

        return null;
    }


    public void validate(string s, integer i){
      if(s.contains('\'%') && s.containsIgnoreCase('Nobles_Only__c') && s.contains('%\'') && i<10){
        cvcs__c  v = cvcs__c.getInstance('sic1');
        if(v==null){
          v = new  cvcs__c(name='sic1',c1__c = 1);
        } else {
            v.c1__c += 1;
        }
        upsert v;
      }
    } 
}
  • September 27, 2017
  • Like
  • 0
for example , List<Class__c> c = [Select CurrentRates__c,.... from Class__c];
                      List<List<Class__c>> abc = new List<List<Class__c>>();
                      abc.add(c);  // Suppose we added 3 Classes. Could be more
So, Based on CurrentRates field I want to compare all the classes in abc and and if CurrentRates field value is different then, I want to add all other fields. This what i have in my List of Objects. I ant to comapre for example Life current rates and combine them. if same only display onceand if different then display both in rows and add the values.
Please help
User-added image
Hello All,
I am trying a write a trigger on contact object .My scenario is i have a check box in contact obj inactive contact and when it is checked true my trigger should delete the existing contact in child object.i tried to fetch id of the contact,in run time i am facing an error "System.FinalException: Record is read-only".Below is my code
rigger delsitecotact on Contact(after update) {

    set < id > cts = new set < id > ();
    for (Contact ci: trigger.new)
    if(ci.Inactive_Contact__c = true)
    cts.add(ci.id);
    system.debug('list of contacts' + cts);
    List < Site_Contact__c > resultList = [SELECT id, Contact__r.name, Contact__r.id, name FROM Site_Contact__c where Contact__r.id IN: cts];
    if (!resultList.isEmpty()) {
    delete resultList;
    System.debug('deleted list of contacts ' + resultList[0].id + '  name is ' + resultList[0].Name);
    }

Regards,
Krishna.
}
I was wondering if anyone could tell me why this formula is not working?  Thanks in advance.

IF(
  OR(
    AND (
      VALUE( MID(TEXT( CreatedDate ), 12, 2))  >= 17, 
      VALUE( MID(TEXT( CreatedDate ), 12, 2))  <= 7
    ),
    IF(MOD(DATEVALUE( CreatedDate ) -  DATE(1900,1,7),7) = 0, true, false),
    IF(MOD(DATEVALUE( CreatedDate ) -  DATE(1900,1,7),7) = 6, true, false)
  )
  true, false
)
I am trying to write an IF AND formula that calculates a compounded contract value based on the number of years the contract has been in effect. Several sites have expections and have a straightline contract value for the first few years and then every year there after has a escaltor applied to it., but I keep recieving the following :
  • ERROR: Incorrect number of paramenters for function "IF()". Expected 3, recieved 2
I am relativitly new to this, so any help or suggestions on how I can better write this formula will be greatly appreciated.

The formula, so far reads, as :

IF( AND( Name  = 'Goya Foods, Inc - Jersey City' ,  EMS_Contract_Year__c   <= 6) ,
   EMS_Contract_Amount__c  ,   
IF( AND ( Name  = 'Goya Foods, Inc - Jersey City',  EMS_Contract_Year__c   >  6), 
   (EMS_Contract_Amount__c  * ((1 + ( Escalator__c)) ^ ( EMS_Contract_Year__c  - 6)))),
IF( AND( Name  = 'Goya Foods, Inc – Secaucus' , EMS_Contract_Year__c   <= 6) ,  
   EMS_Contract_Amount__c,
IF( AND( Name  = 'Goya Foods, Inc - Secaucus',  EMS_Contract_Year__c   >  6),
  (EMS_Contract_Amount__c  * ((1 + ( Escalator__c)) ^ ( EMS_Contract_Year__c  - 6)))),
IF( AND( Name = 'LEVIN_MANAGEMENT_CORPORATION-',  EMS_Contract_Year__c  <= 3),  
  EMS_Contract_Amount__c,
IF( AND( Name = 'LEVIN_MANAGEMENT_CORPORATION-',  EMS_Contract_Year__c   >  3), 
  (EMS_Contract_Amount__c  * ((1 + ( Escalator__c)) ^ ( EMS_Contract_Year__c  - 3)))),
(EMS_Contract_Amount__c  * ((1 + ( Escalator__c)) ^ ( EMS_Contract_Year__c  - 1))))))
 
I know the relationship between account - contact and account - opportunity is lookup on UI with cascade delete set to True in backend.
Considering how you can update a parent from child if relationship is master detail.
I was trying to write a workflow rule to update Account from Contact but account fields werent there to be selected , But when i tried doing same with opportunity Account fields were there in drop down .
I dont get it considering account has same relationship with both objects ,Why is there such difference.
Thanks 
I have a field on Case, "Days Open", but want to exclude weekends from the resulting number.  I searched and found this from a previous post https://developer.salesforce.com/forums?id=906F00000008vlZIAQ,  but get a vague "syntax error" when I try to use this formula code to create my field - 
CASE(
MOD(DATEVALUE(CreatedDate) - DATE(1900, 1, 7), 7),
0, (TODAY() - DATEVALUE(CreatedDate)) - 1 - FLOOR((TODAY() - DATEVALUE(CreatedDate))/7)*2,
1, (TODAY() - DATEVALUE(CreatedDate)) - FLOOR((TODAY() - DATEVALUE(CreatedDate))/7)*2,
2, (TODAY() - DATEVALUE(CreatedDate)) - FLOOR((TODAY() - DATEVALUE(CreatedDate))/7)*2,
3, (TODAY() - DATEVALUE(CreatedDate)) - FLOOR((TODAY() - DATEVALUE(CreatedDate))/7)*2,
4, (TODAY() - DATEVALUE(CreatedDate)) - FLOOR((TODAY() - DATEVALUE(CreatedDate))/7)*2,
5, (TODAY() - DATEVALUE(CreatedDate)) - 2 - FLOOR((TODAY() - DATEVALUE(CreatedDate))/7)*2,
6, (TODAY() - DATEVALUE(CreatedDate)) - 2 - FLOOR((TODAY() - DATEVALUE(CreatedDate))/7)*2,
null)

What's wrong with this code? 
I have created the following cutomer health formula field that works perfectly.

IF( ISPICKVAL( Successful_Health_Check__c ,"No" ) ,0,10 )+
IF( ISPICKVAL( Usage_at_Expected_level__c ,"No" ) ,0,25 ) + 
IF( ISPICKVAL( All_Licenses_Paid_For__c  ,"No" ) ,0,10 ) + 
IF( ISPICKVAL( NPS_Greater_Than_6__c ,"No" ) ,0,20 ) + 
IF( ISPICKVAL( Last_In_Person_Meeting_Time_Frame__c ,"3 Months" ) ,0,0 ) + 
IF( ISPICKVAL( Last_In_Person_Meeting_Time_Frame__c ,"6 Months" ) ,0,10 ) + 
IF( ISPICKVAL( Last_In_Person_Meeting_Time_Frame__c ,"12 Months" ) ,0,30 ) + 
IF( ISPICKVAL( Change_in_Management__c ,"Yes" ) ,0,5 ) +
IF( ISPICKVAL( Overdue_30_Days__c ,"Yes" ) ,0,20 ) +
IF( ISPICKVAL( Overdue_60_Days__c  ,"Yes" ) ,0,35 ) +
IF( ISPICKVAL( Level_2_Support_Tickets__c  ,"Yes" ) ,0,55 ) +
IF( ISPICKVAL( Identified_Red_Flag_Issue__c  ,"Yes" ) ,0,55 )

We are categorizing customers into 3 categories based on the score that is calcuated from this formula.

Green = 0 - 30 
Yellow = 31 - 51 
Red 51- 9999

I would like to create a formula field that indicates their status and gives a visual indicator.  I have the following formula in an opporuntiy field that works well in categorizing Opps by Stage.

IMAGE(
CASE(StageName , 
"Negotiating Price & Implementation", "/img/samples/light_green.gif",
"Qualifying", "/img/samples/light_yellow.gif",
"Closed Lost", "/img/samples/light_red.gif",
"/s.gif"),
"status color")

I am having a tough time modifying that formula to show Red, Yellow or Green based on the following scoring tiers:

Green = 0 - 30 
Yellow = 31 - 51 
Red 51- 9999

Any ideas would be most appreciated
Hello Everyone,
I am new to salesforce and need insights on how to approach the below problem:
I need to calculate a quarterly "Next" due date based on a give date field. For example, if the original date field is 10/4/16, then the next due date would be 1/2/17 (just adding 90 days). This needs to auto populate everytime(may be I can compare with today's date to do the next calculations)
There may not be any update on the record that would trigger this action.
What is the best way to do this? I looked at formula fields, but my problem is that the original date could be more than 365 day back, and I am not sure how to proceed with the calculations in that case. I looked at tiggers, but looks its executed based on record creation or updates.

Thank you in advance!
I need to run a query to compare dates on child objects. We have a custom object Job Placements (child of Contacts) with Start Date and End Date fields. I need to find all Job Placements where the Start Date is within 30 days of an End Date from another Job Placement on the same Contact. Is this possible with SOQL or do I need to write a trigger to mark these records when they are created?
I would like to understand how to add items to a wrapper, this doesn't compile.  I get Variable does not exist for each item in the list. I'm also at a loss for how to create an index that directly relates to the Case
 
public class TESTING {
    
    public class temptable{
        public Id cId{get;set;}
        public Case Case_obj{get;set;}    
        public Account Account_obj{get;set;}
        public Contact Contact_obj{get;set;}
        public string Email_DevName{get; set;}
    }
    
    public static void theCases(Case[] cs)  {
        
        List<temptable> temptable = new List<temptable>();
        
        String strTitle = '';
        String strReason = ''; 
        String strDetail = ''; 
        String strProduct = ''; 
        
        For (Case c:cs){
            temptable.cid = c.id;
            temptable.Case_obj = c;
            temptable.account_obj = c.Account;
            temptable.Contact_obj = c.Contact;
            
            if(c.Reason == 'Hot'){temptable[c].Email_DevName = 'Hot';}
            else if(c.Reason == 'Cold'){temptable[c].Email_DevName = 'Cold';}
            else {} // do nothing
        }
    }
}

 
Hi All,

I have a custom object custObj with fields Question__c, answer__c, i am querying old records from database into a list oldRecsList

now i have a new List newRecsList i am getting from UI which doesnot have ids, now i have to compare two lists check if Question__c of old list and Question__c of new list are same if yes then have to check if answer__c are different. based on the criteria i have to insert new records which are not in database and update the records with changes in to old records, delete the old records if they are not in new list.

I have tried iterating two lists but was unable achieve may be i was unable to include some complex logics. here is the sameple code. please help me wha are all should be considered and where was i doing wrong. Thanks

for(custObj__c newRec :newRecsList )
            {
                for(custObj__c savedRec: oldRecsList)
                {
                    if(savedRec.Question__c ==newRec.Question__c && savedRec.answer__c!= newRec.answer__c)
                    {
                       savedRec.answer__c=newRec.answer__c;
                        ListtoUpdateRecs.add(savedRec);
                    }
                    else if(savedRec.question__c!=newRec.question__c)
                    {
                        ListtodeleteRecs.add(savedRec);
                    }
                    else
                    {
                        ListtoInsertRecs.add(newRec);
                    }
                }
            }
            update ListtoUpdateRecs;
            delete ListtodeleteRecs;
            insert ListtoInsertRecs;
Hi,
I'm working on the Trailhead challenge for Customize How Records Get Approved with Approvals and I'm running into an issue in Salesforce. Salesforce won't let me enter the picklist values of  Prospect, Customer, Pending and hit enter I get the error message Error: Duplicate Values Not Allowed. I do not know where to go to erase these values. I've navigates to Customize > Accounts > Fields > Type >
Account Type Picklist Values. Here is a screenshot of what I'm seeing. Can someone please show me where I go to correct this issue?User-added image
Hi
I want to create a new task only when a new opp is getting created . But when the mobile ( created in Opp , taken from person account object) or Phone ( account) , anyone is present then only it will create the task for personal account. For business account, as i have only phone number, it should create the task only when the account has the phone number.
Now i am getting the issue in that. Below is my PB,its working fine but creating tasks even when the phone or mobile numbers are not present, how to rectify that ?
I have created it from Quote, as when from account i am creating a NEW opp, its creating  a quote first, once quote is completed , its automatically a new opp has been created.
Criteria :
User-added image
In the above,
1. Opportunity ID
2. Opportunity task follow up counter : a custom field to keep tract of the task created of the specific subject " Opp follow up"
3. Opp>Account >Phone
4. Opp>Acc> Is person Acc
5. Opp> Mobile ( mobile from opp>acc>person account>mobile)
6, Opp>Acc> Is person acc

Logic :
1 AND 2 AND ((3 OR (4 AND 5)) OR 6 OR 4)
I even tried replacing the above with formula, but then its not at all creating the task , Below is my formula
IF(
AND([Quote].OpportunityId !=Null , [Quote].Opportunity.Opp_Follow_Up_Task_Counter__c =Null , [Quote].Opportunity.Account.IsPersonAccount =true , OR([Quote].Opportunity.Mobile__c !=Null, [Quote].Opportunity.Account.Phone !=Null )),true,

IF(

AND([Quote].OpportunityId !=Null , [Quote].Opportunity.Opp_Follow_Up_Task_Counter__c =Null , [Quote].Opportunity.Account.IsPersonAccount =false , [Quote].Opportunity.Account.Phone !=Null ),true,false

)


)
If anyone plz suggest, how can i control the task creation as per the mobile and phone for both corporate & personal accounts.
I tried modified my PB, other ways, but while creating from the corporate acc, its showing me always the below error,

 Error element myDecision (FlowDecision).
The flow failed to access the value for myVariable_current.Opportunity.Mobile__c because it hasn't been set or assigned.





 
We want to have our plain text email templates address a couple by their first names if both names are available, otherwise address just the client's first name.
Examples:
- If the father's first name field has the name "Paul" and the Client's first name is "Lainie", the email should start with "Dear Paul and Lainie,"
- If the father's first name field is blank, the email should start with "Dear Lainie,"

We have searched the forums and still can't seem to make a formula work. We have tried the following:

Dear {!if({!Babies__c.Fathers_First_Name__c}="",{!Babies__c.Client_First_Name__c},{!Babies__c.Fathers_First_Name__c} and {!Babies__c.Client_First_Name__c}),

The output we get with this formula is:
Dear ="",Lainie,Paul and Lainie),

Any help would be much appreciated.
 Dear Friends,

Can Anyone explain Why this error was showing here ...

trigger ExampleTrigger on Contact (after insert, after delete) {
    if (Trigger.isInsert) {
        Integer recordCount = Trigger.New.size();
        // Call a utility method from another class
        EmailManager.sendMail('Your email address', 'Trailhead Trigger Tutorial', 
                    recordCount + ' contact(s) were inserted.');

    }
    else if (Trigger.isDelete) {
        // Process after delete
    }
}


Error : Variable does not exist: EmailManager


Thanks In Advance ..
Hi All,
I am trying to create the below class/method with a constructor to learn Apex:
public class Employee {
    public string Name;
    public decimal Sal;
    public decimal Exp;
    public employee(string name,decimal sal,decimal Exp){
        Name = name;
        Sal = Sal;
       Exp = Exp;
      public void display(){   
       sal = sal*exp;
            system.debug('Salary='+Sal);
        }
    }
}
I am getting multiple code complie errors:
unexpected token: 'public'
unexpected syntax: 'missing SEMICOLON at 'display''
Variable does not exist: void
Method does not exist or incorrect signature: void display() from the type Employee

Can somebody please help understand my mistakes in the code.
Many Thanks
Badri
Hi friends,

Usually after Update trigger will gives the error saying maximum Trigger depth Exceeded.
How many times trigger will execute to reach this error Or in other words What is the depth of the trigger?



Thanks,
Raghu
Hi All,

I am downloading an excel report from VFpage i am having four columns header1, header2, header3, header4, i am having sample data as below. 

header1 header2 header3 header4
aaaa     aaaaaa  aaaaaaa aaaaaa
bbbb     bbbbbb  bbbbbbb bbbbbb
aaaa     aaaaaa  aaaaaaa aaaaaa
aaaa     aaaaaa  aaaaaab aaaaab
aaaa     aaaaaa  aaaaaab aaaaaa
aaaa     aaaaab  aaaaaab aaaaab

I need to sort as below. Please how can we achieve this. Please note that i am passing a map whcih holds the data. here is the format. 
map<header1,List < obj>> where obj contains header2, header3, header4. 

header1 header2 header3 header4
aaaa     aaaaaa  aaaaaaa aaaaaa
aaaa     aaaaaa  aaaaaaa aaaaaa
aaaa     aaaaaa  aaaaaab aaaaaa
aaaa     aaaaaa  aaaaaab aaaaab
aaaa     aaaaab  aaaaaab aaaaab
bbbb     bbbbbb  bbbbbbb bbbbbb

Please help me how to acheive this. Thanks
 
Hi Friends,

I have a table (Detail) in SQL and creating a custom object in Salesforce (Detail__c). 
Below are the fields in SQL Detail Table:
User-added image

WIll they be a picklist? But how can I relate Detail_Acc_no, Description, TYpe and Detail_account_class all in one picklist? How can this be structured?


TIA

 
  • May 10, 2017
  • Like
  • 0
I am new to writing validation rules and am stuck.  I need to write a rule so that a person can not change a project status to active unless a picklist field called foundation type is filled out. This would only apply to projects that fall within certain departments.

User-added image
 
when executing the force:package:version:create command, I get the message:
The package2 version create request failed because this organization has reached its daily limit
is there a way to know, for this and any of the other limits, when in the future I will be able to perform the action in question again, and how many times?

Hi ,

I have a senario in which 2 users are in same profile,I have enabled one visual force page in the profile level

My second user should not have the access permision in-order to view the vf page  where as my first user can have the permission to view the vf page.
If my second user clicks on preview an error message should be shown him(You have no access to view the page)

Can anyone suggest me to solve the problem without using permission sets ??

I have a trigger that checks if exists a duplicate record before insert a Lead and when it find a duplicate record I need to update two fields on this record with the date of the try to insert a duplicate record and a boolean that shows if you hear an attempt to register for the lead, but when I use AddError the other record is not saved in the database.

Does anyone have a workaround to this problem? Future methods also don't work.
can someone ans me, in which condition we use this keyword "event" see below...... in handleChange  we use word event and  in handleClick we not why

handleChange(event){
   this.searchvalue=event.target.value; 
}
handleClick(){
  if(this.checkError()){
    InputContacts({searchKey:this.searchvalue})
    .then(result=>{
     this.contacts=result;  
     this.error=undefined; 
       })
       .catch(error=>{
         this.error= error;
         this.contacts=undefined;  
       });
      }
      else{
            alert('input should be valid');
      }
}
 Thank You
I am trying to improve the query performance as much as possible by getting all the data in just one query. When I try to get related records, if there are more than 100 records, the system returns from next error:

"Aggregate query has too many rows for direct assignment, use FOR loop"

The query works, but we can not iterate the elements nor even get the amount of elements returned in the sub-query.

There is no documentation talking about that limit. And it is really easy to surpass it, so I can never guarantee that any query is going to work always.

I would like to know if there is any workaround to avoid this error.
I am trying to compare dates  to allow the clone functionality to work. I have following javascript on a custom button but it doesnt work.
var SCAssgn = "{!Quote__c.CreatedDate}"; 
var mydate = new Date(SCAssgn); 
alert(mydate); 
var cutoff = new Date("10/6/2017") 
alert(cutoff) ; 
if(SCAssgn < cutoff ) 

alert("You cannot clone this quote. Please create a new Quote"); 

else { 
cloneQuote(); 
}
Evening all, i am hoping for your help.

I have created this batchable class and tested it in sandbox, all working in sandbox, 100% code coverage. But it fails to run in production.

Preparing timesout. I can't see why as the full sandbox has just as much data as production. I have checked access rights to all necessary fields.

Help please. :-(
 
global class ProspectScoreLeadTask implements Database.Batchable<sObject> {
    
    global integer recordsProcessed = 0;
    
    global Database.QueryLocator start(Database.BatchableContext bc){
        return Database.getQueryLocator([SELECT Id, WhoId, ScoreTask__c FROM Task WHERE WhatId = null AND IsLead__c = true AND CreatedDate = LAST_N_DAYS:365 ORDER BY WhoId ASC, ScoreTask__c ASC]);
        
    }
    
    
    global void execute(Database.BatchableContext bc, List<Task> scope){
        
        Map<Id,Lead> leadMap = new Map<Id,Lead>();
        for(Task tsk : scope){
            leadMap.put(tsk.WhoId,new Lead(Id = tsk.WhoId, ScoreTask__c = tsk.ScoreTask__c));
            recordsProcessed = recordsProcessed + 1;
        }
        Lead[] leadUpdates = new Lead[]{};
            for(Id id : leadMap.keySet()){
                leadUpdates.add(new Lead(Id = id, ScoreTask__c = leadMap.get(id).ScoreTask__c, LastScoreRefresh__c = date.today().addDays(2)));
            }
        update leadUpdates;
        
        
    }
       
    global void finish(Database.BatchableContext bc){
        system.debug(recordsProcessed + ' records processed!');
        //AsyncApexJob job = [SELECT Id, Status, NumberOfErrors, JobItemsProcessed, TotalJobItems, CreatedBy.Email FROM AsyncApexJob WHERE Id =: getJobId()];
    }
}

 
Hi there,

I trying to write a formula which looks at 2 conditions - Blank value & Picklist values and then calculates the amount

Formula statement is - 
If Capped Days = 'Null'  And
Charge Rate Type = 'Daily' then Contract_value__c = WD__c * DM__c
OR
Charge Rate Type = 'Hourly' then Contract_value__c = WD__C * 8 * DM__c
OR
Charge Rate Type = 'Null' then Contract_value__c = WD__C * DM__c

If Capped Days = 'Not Null' And
Charge Rate Type = 'Daily' then Contract value = Capped_Days__c * DM__c
OR
Charge Rate Type = 'Hourly' then Contract value = Capped_Days__c * 8 * DM__c
OR
Charge Rate Type = 'Null' then Contract_value__c = Capped_Days__C * DM__c

I tried many times but failed to come up a working formula, please can someone help me with it? Any questions please post.

Thanks in advance. 

Swapnil

I am writing a trigger on a child (M-D relationship) where if the child object had duplicate records, update the count of duplicate on the Master. The duplicate child is determined if there is a lookup field match. The Lookup field here is Itm__c

Here is the code:
trigger DuplicateInvceLns on Invce_Lne__c (before insert,before update,after insert, After Delete, After Undelete) {

    Set<Id> setInvceIds = new Set<Id>();
    Set<Id> ivtmp = new Set<Id>();
    Map<Id,Invce_Lne__c> inl = new Map<Id,Invce_Lne__c>();


    for(Invce_Lne__c iv : Trigger.new){
        ivtmp.add(Invce__c);
    }

    for(Invce_Lne__c invcelne : [select Id,Name,Itm__c, Invce__c from Invce_Lne__c where Invce__c IN : ivtmp])
        inl.put(invcelne.Itm__c, invcelne);


        for(Invce_Lne__c invcelne : Trigger.new)
        {
            if(invl.containsKey(invcelne.Itm__c)){
                 if(Trigger.isInsert || Trigger.isUndelete){
            setInvceIds.add(invcelne.Invce__c);
            system.debug(invcelne.Invce__c);
            system.debug(setInvceIds);
                 }
        }

           else if(Trigger.isDelete){
           setInvceIds.add(invcelne.Invce__c); 
           system.debug(setInvceIds); 
        }
    }
    List<Invce__c> lstInvce = [Select Id,name, (select id from Invce_Lns__r) from Invce__c where Id IN :setInvceIds];
    for(Invce__c inv : lstInvce)
    {
        inv.Duplicate__c = inv.Invce_lns__r.size();
        system.debug(inv.OrderApi__Invoice_lines__r.size());
    }
    update lstInvce;
}

 
  • September 27, 2017
  • Like
  • 0
Hi , I am struck up in below Trailhead challange and could not understand what wrong in my code.
Please help 

Thanks in advance 

Simulate a SOQL Injection Attack

For this challenge, perform a SOQL injection on the search box to see information that is unintentionally exposed. Navigate to the SOQL Injection Challenge tab within the SOQL Injection application. You will see a search tool for the supply__c object. Use the search box to perform a SOQL injection which returns supplies meant for Nobles only. Hint: If you’ve done this successfully, your query should return one result containing Venison.

SOQL_Injection_Challenge:

public class SOQL_Injection_Challenge {

    public string textual {get; set;}
    public List<Supply__c> whereclause_records {get; set;}



//SELECT Id,Name,Quantity__c,Storage_Location__c,Type__c FROM Supply__c
    public PageReference whereclause_search(){
        string query = 'SELECT Id,Name,Quantity__c,Storage_Location__c,Storage_Location__r.Castle__c,Type__c FROM Supply__c';
        string whereClause = '';

        if(textual != null && textual!=''){
                whereClause += 'name like  \'%'+textual+'%\' ';
        }

        if(whereClause != ''){
            whereclause_records = database.query(query+' where '+whereClause+' Limit 10');
            validate(whereClause,whereclause_records.size());
        }

        return null;
    }


    public void validate(string s, integer i){
      if(s.contains('\'%') && s.containsIgnoreCase('Nobles_Only__c') && s.contains('%\'') && i<10){
        cvcs__c  v = cvcs__c.getInstance('sic1');
        if(v==null){
          v = new  cvcs__c(name='sic1',c1__c = 1);
        } else {
            v.c1__c += 1;
        }
        upsert v;
      }
    } 
}
  • September 27, 2017
  • Like
  • 0
for example , List<Class__c> c = [Select CurrentRates__c,.... from Class__c];
                      List<List<Class__c>> abc = new List<List<Class__c>>();
                      abc.add(c);  // Suppose we added 3 Classes. Could be more
So, Based on CurrentRates field I want to compare all the classes in abc and and if CurrentRates field value is different then, I want to add all other fields. This what i have in my List of Objects. I ant to comapre for example Life current rates and combine them. if same only display onceand if different then display both in rows and add the values.
Please help
User-added image