function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Guru sfdcGuru sfdc 

Method does not exist or incorrect signature contains (String) :

Hi All,
When we are trying to save the trigger getting error like “Method does not exist or incorrect signature: [Id].contains (String) ”.Please help us on this

Please check my below bit of logic:

List<Opportunity_Splits__c> PODS = [SELECT Account__c,Amount__c,Id,Name,Opportunity__c,Split_Percentage__c FROM Opportunity_Splits__c where Opportunity__c IN:trigger.newmap.keyset()];
    for(Opportunity_Splits__c POS: PODS ){
        if(opppartnerorderMap.containskey(POS.Opportunity__c))
        opppartnerorderMap.get(POS.Opportunity__c).add(POS);
        else{
            List<Opportunity_Splits__c> podslist = new List<Opportunity_Splits__c>();
            podslist .add(POS);
            opppartnerorderMap.put(POS.Opportunity__c,podslist);
        }
    }

for(Opportunity_Splits__c POS : opppartnerorderMap.get(opp.id))
                        if(POS.Account__c.contains(' platforms')&&(date.valueOf(opp.createdDate).daysBetween(date.valueOf(opp.CloseDate))<=30))
                        {opp. Checkbox =true;
                            break;
                        }
                        else if(!POS.Account__c.contains('platforms')&&(date.valueOf(opp.createdDate).daysBetween(date.valueOf(opp.CloseDate))<=45))
                        opp.Checkbox=true;

Thanks

 
rajat Maheshwari 6rajat Maheshwari 6

Hi,

Error comes as because, you were trying to check "platforms" on Id.

Ex - POS.Account__c will give Id of account, Instead you can write
POS.Account__r.Name.contains('platforms')

 

Please let me know if it works or not.

Thanks

NagendraNagendra (Salesforce Developers) 
Hi Guru,

May I suggest you please check with below link from stack exchange community with similar issue and suggested work around.

http://salesforce.stackexchange.com/questions/22700/method-does-not-exist-or-incorrect-signature-id-containsstring

Hope this helps.

Regards,
Nagendra.
Guru sfdcGuru sfdc
Hi Rajat Maheshwari,

Thanks for your reply. I have tried same thing which are mentioned above. But when am trying to save my Opportunity Record getting below error:

"SObject row was retrieved via SOQL without querying the requested field: Opportunity_Splits__c.Account__r: "

For loop is :if(POS.Account__r.name.contains('GE Intelligent platforms')&&(date.valueOf(opp.createdDate).daysBetween(date.valueOf(opp.CloseDate))<=30))

MY SOQL is:
SELECT Action_Type__c,Amount__c,Id,Name,Opportunity__c,Split_Percentage__c,Opportunity_Splits__c.Account__c FROM Opportunity_Splits__c where Opportunity__c IN:trigger.newmap.keyset().

Please help me on this.

​Thanks
 
rajat Maheshwari 6rajat Maheshwari 6

Hi Guru,

Please include Account__r.Name in soql query just like below : - 

SELECT Action_Type__c,Amount__c,Id,Name,Opportunity__c,Split_Percentage__c,Opportunity_Splits__c.Account__c, Account__r.Name FROM Opportunity_Splits__c where Opportunity__c IN:trigger.newmap.keyset().

Guru sfdcGuru sfdc
Hi Rajat,
 
Thank you so much!. Sorry for the late response. My code is saved succefully without error. But when am trying to change the opty stage name getting error like "Attempt to de-reference a null object" 
 
Effected line is:
 for(Opportunity_Splits__c POS : opppartnerorderMap.get(opp.id))   if(POS.Account__r.name.contains('platforms')&&(date.valueOf(opp.createdDate).daysBetween(date.valueOf(opp.CloseDate))<=30))
{
opp.checkbox=true;
 
Can you please help me on this.
 
​Thanks
 
rajat Maheshwari 6rajat Maheshwari 6

Hi Guru,

Attempt to de-reference a null object occurs , when we try to manipulate on null things,

Please use check to prevent from error, just in below code snippet :  - 

 if(opppartnerorderMap!=null && opppartnerorderMap.containsKey(opp.id))
    {
 for(Opportunity_Splits__c POS : opppartnerorderMap.get(opp.id))   if(POS.Account__r.name.contains('platforms')&&(date.valueOf(opp.createdDate).daysBetween(date.valueOf(opp.CloseDate))<=30))
{
opp.checkbox=true;

}
}

Pleas let me know in case of any issue.

 

Thanks

Rajat Maheshwari

rajatzmaheshwari@gmail.com

Guru sfdcGuru sfdc
Hi Rajat,

I have used same snippet my code but still getting same error.Please check my complete for loop and help me where i made the mistake.

for(opportunity opp : trigger.new)
{   
system.debug('testing opp'+opp);
if(oppMap.get(opp.id)!=null)
{
System.debug('*******--***'+opp);
for(Opportunitysplit opss : oppMap.get(opp.id))
{
if((opp.CategoryName=='Best' || opp.CategoryName=='Commit') 
&& opp.RecordTypeId== devRecordTypeId 
&& sscmap!=null 
&& sscmap.get(opss.SplitOwnerid)!=null                    
&& ((sscMap.get(opss.SplitOwnerid).Quota__c!=null
&& (sscMap.get(opss.SplitOwnerid).Quota__c/2 <= opss.SplitAmount))
|| (sscMap.get(opss.SplitOwnerid).Manager_Quota__c!=null 
&&  opss.SplitAmount >=sscMap.get(opss.SplitOwnerid).Manager_Quota__c*25/100)))
{   system.debug('testing opp'+opss );
opp.CheckBox=true;
break;
}

else if((opp.CategoryName=='Best' || opp.CategoryName=='Commit') && 
( OppTeamMapChannelRoles.get(opp.id) > 1 || OppTeamMapAccountRoles.get(opp.id) > 1 )){
opp.CheckBox=true;
}                  

//else if(opppartMap!=null && opppartMap.get(opp.id)!=null)
else if((opp.CategoryName=='Best' || opp.CategoryName=='Commit') && opppartnerorderMap!=null && opppartnerorderMap.get(opp.id)!=null && opppartnerorderMap.containsKey(opp.id))

//if(opppartnerorderMap!=null && opppartnerorderMap.containsKey(opp.id))  

for(Opportunity_Splits__c POS : opppartnerorderMap.get(opp.id)) 
if(POS.Account__r.name.contains(' platforms')&&(date.valueOf(opp.createdDate).daysBetween(date.valueOf(opp.CloseDate))<=30))
{opp.CheckBox=true;
break;
}
else if(!POS.Account__r.name.contains('platforms')&&(date.valueOf(opp.createdDate).daysBetween(date.valueOf(opp.CloseDate))<=45))
opp.CheckBox=true;
else{
system.debug('testing opp');
opp.CheckBox=false;
}
}

else{
system.debug('testing opp');
opp.CheckBox=false;
}
//}
}
}
}

Thanks
rajat Maheshwari 6rajat Maheshwari 6

Hi Guru,

Please try with that code snippet : - 

for(opportunity opp : trigger.new)
{   


if(oppMap!=null && oppMap.containsKey(opp.id))
{
  for(Opportunitysplit opss : oppMap.get(opp.id))
   {
       if((opp.CategoryName=='Best' || opp.CategoryName=='Commit') 
&& devRecordTypeId!=null && opp.RecordTypeId== devRecordTypeId 
&& sscmap!=null 
&& sscmap.containsKey(opss.SplitOwnerid)                    
&& ((sscMap.get(opss.SplitOwnerid).Quota__c!=null && opss.SplitAmount!=null
&& sscMap.get(opss.SplitOwnerid).Quota__c/2 <= opss.SplitAmount)
|| (sscMap.get(opss.SplitOwnerid).Manager_Quota__c!=null 
&& opss.SplitAmount && opss.SplitAmount >=sscMap.get(opss.SplitOwnerid).Manager_Quota__c*25/100)))




{   
system.debug('testing opp'+opss );
opp.CheckBox=true;
break;
}

else if((opp.CategoryName=='Best' || opp.CategoryName=='Commit') && OppTeamMapChannelRoles!=null && OppTeamMapChannelRoles.containsKey(opp.id) && OppTeamMapAccountRoles!=null && OppTeamMapAccountRoles.containsKey(opp.id) && ( OppTeamMapChannelRoles.get(opp.id) > 1 || OppTeamMapAccountRoles.get(opp.id) > 1 )){
opp.CheckBox=true;
}                  

//else if(opppartMap!=null && opppartMap.get(opp.id)!=null)
else if((opp.CategoryName=='Best' || opp.CategoryName=='Commit') && opppartnerorderMap!=null && opppartnerorderMap.containsKey(opp.id))
{ 
//if(opppartnerorderMap!=null && opppartnerorderMap.containsKey(opp.id))  

for(Opportunity_Splits__c POS : opppartnerorderMap.get(opp.id)) 
if(POS.Account__c!=null && POS.Account__r.name.contains(' platforms')&&(date.valueOf(opp.createdDate).daysBetween(date.valueOf(opp.CloseDate))<=30))
{
opp.CheckBox=true;
break;
}
else if(POS.Account__c!=null && !POS.Account__r.name.contains('platforms')&&(date.valueOf(opp.createdDate).daysBetween(date.valueOf(opp.CloseDate))<=45))
opp.CheckBox=true;
else{
system.debug('testing opp');
opp.CheckBox=false;
}
}

else{
system.debug('testing opp');
opp.CheckBox=false;
}
//}
}
}
}

Thanks
rajat Maheshwari 6rajat Maheshwari 6
Hi Guru,

Does your issue get solved ? If not then pls share the full code over here.

Thanks
Guru sfdcGuru sfdc
Hi Rajat,

Thanks your entire help..sorry for the late response..Actually i was on leave.Issue was resolved.But again one problem from same trigger.

The problem is: In scorecard object when matching any criteria then in the opportunity "Checkbox” should be true. Which is working fine my question is after matching any criteria in scorecard object in the opportunity need to updated checkbox = check when refreshing the opty page. Here we are updating the field every time which is not correct 

I have written the trigger before event.Can you please help me on this.

Thanks



 
rajat Maheshwari 6rajat Maheshwari 6

Hi Guru,

If scorecard object is child of Opportunity, then you can simply use this statement to update checkbox true in opportunity : - 

scorecard.Opportunity__r.checkbox = true;

Here scorecard is childObject API

Opportunity__r represent relationship to opportunity, If Opportunity__c is lookup field to scorecard.

 

Please let me know in case of any help :)

Thanks

 

Guru sfdcGuru sfdc
Hi Rajat,

There is no relationship between Opportunity and Scorecard. How we can update field without editing in the opportunity record? Every time editing is not good way. Please suggest me.

​Thanks
 
rajat Maheshwari 6rajat Maheshwari 6

Hi Guru,

As per your requirement, you want to update opportunity checkbox field due to changes done in scorecard object to match the record.

Could you please provide the more information in stepwise about what is the matching criterion?

Thanks

Guru sfdcGuru sfdc
Hi Rajat,

The problem is : In scorecard object  matching any criteria 1 & 2 point. Then in the opportunity "Deal: should be true. Which is working fine my question is after matching any criteria in scorecard object in opportunity i need to updated deal = check when refresh the opty page not updating any field.
 Please see below scenarios.
 
1. If the "Forecast Category" equals to Best Case or Commit AND If the Opportunity split member amount is >= 50% of the user’s quota mentioned on sales scorecard object Then Deal = check.
 
2. If the "Forecast Category” equals to Best Case or Commit AND If the Opportunity split member amount is >= 25% of the user’s manager quota mentioned on sales scorecard object Then Deal = check.
 
3. If the "Forecast Category” equals to Best Case or Commit AND If there is more than 1 person on the Oppty Team as SW account manager or the SW channel manager. Then Deal = check.
 
4.If the "Forecast Category " equals to Best Case or Commit AND
If the related list ”Partners Order Split” does not contain any record or has only “platforms” then it is a direct opportunity and if it is closing within 30 days it was created. Then Deal = check.
 
5.If the "Forecast Category " equals to Best Case or Commit AND If the related list ”Partners Order split ” contains  records other than “platforms” then it is a channel opportunity and if it is closing within 45 days it was created. Then Deal = check.
 
Based on above scenario’s i have written one trigger on Opportunity.
 
 
The problem is: In scorecard object matching any criteria 1 & 2 point. Then in opportunity Deal should be true. Which is working fine my question is after matching any criteria in scorecard object in opportunity i need to updated deal = check when refresh the pouty page not updating any field.


If you want i will provide my entire Trigger.Please help me on this.

Thanks
rajat Maheshwari 6rajat Maheshwari 6

Hi Guru, As per your concern, You want to automatically update the deal checkbox, on basis of matching criterion instead to edit the records to fire the trigger.

As per my knowledge, I will suggest you to utilize the schedule Apex to run on the records of opportunity on basis of matching crietrion everyday at specified time.

Please let me know your understanding, 

Thanks

Guru sfdcGuru sfdc
Hi Rajat,

Thanks for your suggestion. As per my understand instead of trigger we will achieve this through batch apex? There is no other way to do achieve from trigger? If not I will provide my entire trigger code can you please help me to creating a batch for the same. That would be great help for us. Sorry for the trouble.

Thanks
 
rajat Maheshwari 6rajat Maheshwari 6

Hi Guru,

please let me know your understanding on my gmail account - rajatzmaheshwari@gmail.com, I will try to assist you via gmail.

Working of Schedule Apex (Batch apex) - : 

1. It will fetch the opportunity records and run the process on them to execute the update operation on checkbox field on basis of matching criterion . 

2. Scheduled time is upto you, either you can run everyday at specific time .

Thanks

Guru sfdcGuru sfdc
Thanks rajat,I will follow-up via gmail