• Leon Morocki
  • NEWBIE
  • 175 Points
  • Member since 2012

  • Chatter
    Feed
  • 6
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 25
    Replies

Hi All,

I'm a new coder and this is my first trigger. I am trying to match a field on the custom object with accounts on insert and update. I get save error on "Method does not exist or incorrect signature: map_CountryPostcode_to_SalesRepSC.containsKey(String)" I have underlined the line where the error occurs.

 

What I am trying to do is match the CountryPostcode field in custom object Sales_territory with concatenated account billing country and account billing postcode.

 

Thanks for your help!

 

 

trigger Assign_Sales_Rep on Account (before insert, before update) {

 // Grab Terriory information based on CountryPostcode
 	map<String, String> map_CountryPostcode_to_SalesRepCS = new map<String, String>();
 	map<String, String> map_CountryPostcode_to_SalesRepM = new map<String, String>();
 	
 	string AccCountryPostcode = '';	

	for (Sale_Territory__c [] li_Sale_Territory: [ select CountryPostcode__c,
											Sales_Rep_CS__c,
											Sales_Rep_M__c
										from Sale_Territory__c
										]) 
	{
		for(Sale_Territory__c sSale_Territory : li_Sale_Territory)
		{
			map_CountryPostcode_to_SalesRepCS.put(sSale_Territory.CountryPostcode__c, sSale_Territory.Sales_Rep_CS__c);
			map_CountryPostcode_to_SalesRepM.put(sSale_Territory.CountryPostcode__c, sSale_Territory.Sales_Rep_M__c);
			
		}								
	}
	
	
    for (Account sAccount : trigger.new)
    {
    	AccCountryPostcode = 'sAccount.BillingCountry'+'sAccount.BillingPostalCode';
    	if (sAccount.BillingPostalCode == null || sAccount.BillingPostalCode == '' || sAccount.BillingPostalCode == ' ' || sAccount.BillingCountry = Null || sAccount.BillingCountry = '' ||sAccount.BillingCountry = ' ')
           {
              //sAccount.ShippingPostalCode.AddError('Billing Postal Code OR Billing Country can not be null');
           }
           else 
           {
           		if (map_CountryPostcode_to_SalesRepSC.containsKey(AccCountryPostcode))
           		{
           			sAccount.Sales_Rep_CS__c = map_CountryPostcode_to_SalesRepCS.get(AccCountryPostcode);       			
           		}
           		else
           		{
           			sAccount.Sales_Rep_CS__c ='';
           		}
           		if (map_CountryPostcode_to_SalesRepM.containsKey(AccCountryPostcode))
           		{
           			sAccount.Sales_Rep_M__c = map_CountryPostcode_to_SalesRepSC.get(AccCountryPostcode);       			
           		}
           		else
           		{
           			sAccount.Sales_Rep_M__c ='';
           		}
           }           
    }


}

 

 

  • July 13, 2012
  • Like
  • 0

I want to monitor changes to this field using a trigger, but cannot figure out where it's located.  This field only seems to be available via UI and API.

I have the following trigger.

 

To summarize: when a record is inserted into the object of this trigger if there is a related parent record it looks up and sets 2 fields on that record.

 

trigger SetDJELFromDepreciationSchedule on Depreciation_Journal_Entry_Line__c (Before Insert) 
{      
     for(AcctSol__Depreciation_Journal_Entry_Line__c objDJEL : Trigger.new)    
     {      
        if (objDJEL.AcctSol__Depreciation_Schedule__c != null)
        {          
           AcctSol__Depreciation_Schedule__c TheDS = 
              [select AcctSol__Accum_Depr_GL_Acct__c, AcctSol__Depr_Exp_GL_Acct__c from         
              AcctSol__Depreciation_Schedule__c where Id  
              = :ObjDJEL.AcctSol__Depreciation_Schedule__c];                        
           if(objDJEL.AcctSol__Credit_GL_Account__c == null)          
           {              
            objDJEL.AcctSol__Credit_GL_Account__c = TheDS.AcctSol__Accum_Depr_GL_Acct__c;          
           }          

           if(objDJEL.AcctSol__Debit_GL_Account__c == null)          
           {              
            objDJEL.AcctSol__Debit_GL_Account__c = TheDS.AcctSol__Depr_Exp_GL_Acct__c;          
           }     
      }    
  } 
}

 This code was written back in May and I can confirm that it works. But now all of a sudden the Force.com Security Source Code scanner is rejecting it.

 

CWE ID 10540

This rule identifies Apex where SOQL (salesforce.com Object Query Language) or SOSL (salesforce.com Object Search

Language) statements are executed within a loop.

 

I would ask how this code passed a test a couple weeks ago and now fails but I guess I don't really care - 'tis not my business to understand the rules - just to obey them :-)

 

I was wondering if someone could show me the easiest way to solve this problem ?

(I have some theories but I am also very new at this so I want to check with someone with more experience)

 

Thanks in Advance for your Assistance,

AngiB

 

Hi,

 

I have a custom object A that has a lookup relationship with another custom object B. Is it possible that once I filled up the reference to object B, the form automaticallys add another lookup field to the same custom object B so that I can have more than one look up?

 

Thanks!

I am getting an exception because one of my queries is not returning results, I'm not sure why, can you take a look?

This is the line that's causing the problem: List<Quote> Synced = [SELECT Synced_Quote_Id__c FROM Quote WHERE Id = :quotelid[0].Id];

 

Here's the rest of the code, if that helps.  Thanks!

 

trigger SyncdQuoteUpdate onMilestone1_Project__c (beforeinsert, beforeupdate) {

Id INVLI = trigger.new[0].Invoice_Line_Item__c;

String SyncedQuote = trigger.new[0].Synced_Quote__c;

Date breakdate = Date.newinstance(2012, 7, 8);

Date CreationDate = trigger.new[0].Created_Date__c;

System.Debug(INVLI);

List<QuoteLineItem> quotelid = [SELECT QuoteId FROM QuoteLineItem WHERE Id = :INVLI];

List<Quote> Synced = [SELECT Synced_Quote_Id__c FROM Quote WHERE Id = :quotelid[0].Id];

if ( CreationDate > breakdate ) {

if (SyncedQuote == null) {

trigger.new[0].Synced_Quote__c = Synced[0].Id;

}

}

}

  • July 10, 2012
  • Like
  • 0

I am trying to download a file attached to a chatter feed. Barring extensions and other naming issues, there is an interesting problem:

 

I get a fresh OAuth access token from the stored refresh token, but every time I try to download the file I get a 401 response containing

 

[{"message":"Session expired or invalid","errorCode":"INVALID_SESSION_ID"}]

 

Does anyone have had a similar issue? How can I unblock this? I have read the other messages regarding this but the proposed solutions (if any) do not work for me.

 

This is the command I use to download the file

 

curl -v https://na9.salesforce.com/services/data/v25.0/chatter/files/069E0000000UylDIAS/content -H "Authorization: OAuth xxDExxxxxxxxZCxx%21ARsAQGWxOZVEP.GemGLJ.PTYPGdVxcynRHBB9ExtYCxhgD1UJ6kFR_yVPqOofFZvLEmqxeXMtgXqBVxzvxGGqP_dAPxEvNlx"

 

(I've tried "Bearer" instead of "OAuth" in the auth header, as it's the word I use for the REST API, but the result is the same)

 

(some numbers and letters have been changed to "x" in the token, to protect it. It will expire in any case)

 

 

Thanks to everyone!

 

 

Can anybody help me in resolving the below issue.

 

I have written a visualforce page consisting of picklist.When I select a value in the picklist the value should be passed to a variable in controller class.I am not getting the selected value in the variable.

 

/////////My Visualforce page

 

 

<apex:page StandardController="User" id="thePage" Extensions="UserData"> 

<apex:form >

<apex:pageBlock title="SelectUsers" id="USERSLIST" mode="edit">

<h1>Update Sales Co-ordinator for the users in Particular Region</h1>

<br></br>

Select Region of the User: <apex:inputField id="startMode" value="{!User.Region__c}" />

<br></br>

<apex:commandButton value="Search" action="{!doSearch}" status="myStatus">

</apex:commandButton>

<br></br>

</apex:pageblock>

</apex:form> 

</apex:page>

 

 

 

//////My Controller

 

public class UserData {

 PUBLIC String usr{get;set;}

PUBLIC List<selectOption> usrs;

List<User> results=new List<User>();

List<Id> userlist=new List<Id>();

String Regionid;

String Region;

public UserData(ApexPages.StandardController controller)

{

}

public Pagereference doSearch()

{

//selected picklistvalue should be passed to the below query

results = [select Name from User Where id=:??????];

system.debug('USERSLISTFOR REGION$$$$'+results);

return null;

}

 

public List<User> getResults()

{

return results;

}

}

 

 

Can anyone please help me in resolving the issue.

 

Thanks...

 

 

 

Please provide a

 

We have two custom objects: Invitation and Invitation Card.  We have already selected list of companies to Invitation.  We want to have a trigger to create Invitation Card records after user updates the range of Invitation Card No. to in Invitation record.  Below is our trigger but we found the system creates two Invitation Card for each number.  Anyone can help me to fix it?  Thank you.

 

public list<Invitation_Card__c> card {get;set;}

    card = new list< Invitation_Card __c>();

   

    for(Invitation__c o: Trigger.new){

        if (o.Start_No__c != null &&  

             o.Start_No__c != System.Trigger.oldMap.get(o.Id).Start_No__c) {   

                  

        integer a = integer.valueof(o.Start_ No__c);

        integer b = integer.valueof(o.End_ No__c) + 1;

       

        for(integer i=a; i<b; i++){

           card.add(new Invitation_Card__c(

            Name = string.valueof(i),

            Date __c = date.Today(),

            Invitation__c=o.Id,

            Company__c = o.Company__c));

        }//end for

       

        }//end if

              

    }//end for

           

    insert card;

I am displaying the name of the asset on a page like this <apex:outputField id="CaseField3" value="{!Case.AssetId}"/>.

 

This displays the name of the asset as a link since this is a lookup relationship, therefore, the user can click on it and is taken to the asset page. I would like to prevent that from happening, is there a way to remove the hyperlink and just display the name? or at least don't do anything if the user clicks on the link ?

 

 

Hi All,

I'm a new coder and this is my first trigger. I am trying to match a field on the custom object with accounts on insert and update. I get save error on "Method does not exist or incorrect signature: map_CountryPostcode_to_SalesRepSC.containsKey(String)" I have underlined the line where the error occurs.

 

What I am trying to do is match the CountryPostcode field in custom object Sales_territory with concatenated account billing country and account billing postcode.

 

Thanks for your help!

 

 

trigger Assign_Sales_Rep on Account (before insert, before update) {

 // Grab Terriory information based on CountryPostcode
 	map<String, String> map_CountryPostcode_to_SalesRepCS = new map<String, String>();
 	map<String, String> map_CountryPostcode_to_SalesRepM = new map<String, String>();
 	
 	string AccCountryPostcode = '';	

	for (Sale_Territory__c [] li_Sale_Territory: [ select CountryPostcode__c,
											Sales_Rep_CS__c,
											Sales_Rep_M__c
										from Sale_Territory__c
										]) 
	{
		for(Sale_Territory__c sSale_Territory : li_Sale_Territory)
		{
			map_CountryPostcode_to_SalesRepCS.put(sSale_Territory.CountryPostcode__c, sSale_Territory.Sales_Rep_CS__c);
			map_CountryPostcode_to_SalesRepM.put(sSale_Territory.CountryPostcode__c, sSale_Territory.Sales_Rep_M__c);
			
		}								
	}
	
	
    for (Account sAccount : trigger.new)
    {
    	AccCountryPostcode = 'sAccount.BillingCountry'+'sAccount.BillingPostalCode';
    	if (sAccount.BillingPostalCode == null || sAccount.BillingPostalCode == '' || sAccount.BillingPostalCode == ' ' || sAccount.BillingCountry = Null || sAccount.BillingCountry = '' ||sAccount.BillingCountry = ' ')
           {
              //sAccount.ShippingPostalCode.AddError('Billing Postal Code OR Billing Country can not be null');
           }
           else 
           {
           		if (map_CountryPostcode_to_SalesRepSC.containsKey(AccCountryPostcode))
           		{
           			sAccount.Sales_Rep_CS__c = map_CountryPostcode_to_SalesRepCS.get(AccCountryPostcode);       			
           		}
           		else
           		{
           			sAccount.Sales_Rep_CS__c ='';
           		}
           		if (map_CountryPostcode_to_SalesRepM.containsKey(AccCountryPostcode))
           		{
           			sAccount.Sales_Rep_M__c = map_CountryPostcode_to_SalesRepSC.get(AccCountryPostcode);       			
           		}
           		else
           		{
           			sAccount.Sales_Rep_M__c ='';
           		}
           }           
    }


}

 

 

  • July 13, 2012
  • Like
  • 0

Hi,

is it possible to call a Batch Apex from an execute method of another Batch Apex? I've read in another post that it won't work from a finish method, but maybe it might work from an execute method?

Thx!

Marco

I want to monitor changes to this field using a trigger, but cannot figure out where it's located.  This field only seems to be available via UI and API.

Hi Friends,

 

I am trying strikeiron verifyemail webservices.I have writtern apex class and from this class I try to call verifyemail web services of strikeiron.

 

When I exceute it using anonymous block,I get the following error:-

 

System.CalloutException: IO Exception: Unauthorized endpoint, please check Setup->Security->Remote site settings. endpoint = http://ws.strikeiron.com/StrikeIron/EmailVerify5/EmailVerification

 

What can be the reason for this error and what can I do to get rid of this error.

 

In my Apex class I  have done authenictaion by providing useraname and passord and then I am calling function to verify email.

 

Can somebody throw some light on it?

 

Here comes the code:-

 

public class NewEmail
{
public email2.SIWsOutputOfVerifyEmailRecord NewEmail()
{

Email2.EmailVerificationSoap temp=new Email2.EmailVerificationSoap();
temp.licenseinfo=new email1.licenseinfo();
temp.licenseinfo.registereduser=new email1.registereduser();
temp.licenseinfo.registereduser.userid='chinglish1234@gmail.com';
temp.licenseinfo.registereduser.password='strike957';
email2.SIWsOutputOfVerifyEmailRecord myresponse=new email2.SIWsOutputOfVerifyEmailRecord();
myresponse=temp.VerifyEmail('nitin009_9@yahoo.com',20); 
System.debug('The value in the myreposne is'+myresponse);
return myresponse;

}
}

 

 

Thanks,

Trick

 

 

I am new to apex and am trying to build an apex schedule class that runs everyday. If the account review date for commisions is two weeks (14 days) away the scheduler will send an email to our Sales Department.

 

I think I have all the information I need. I have a made a class that implements the schedulable interface.

 

I have a system schedule method but I don't know where to put it....in the scheduable class or in a new class?

 

Do I have to make a test class for this once my other code is all right? How do I build a test class?

 

Here is my code:

 

global class AccountReviewScheduler implements Schedulable {

 

   global void execute (SchedulableContext ctx) { //what does this line of code do?//

 

{

SendEmail();

}

 

 

public void SendEmail()

{

 

      if (Account.Next_Account_Review_Date_c == System.Today().addDays(14))

{

 

                 Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();

                 Mail.setTemplateId('00XF0000000LfE1;);

                Messaging.sendEmail(new Messaging.SingleEmailMessage[] {mail });

}

 

}

 

// I'm not sure how to link this information to the previous class, make another one? I don't think I can put it in the above class. This schedules my class to run every day at 2:00 am.

 

newScheduledClass m = new newScheduledClass();  

//schedule set for 2am everyday //

String s = '0 0 2 * * ?';

 

// I'm not sure what "Job Name" specifies. I got this code from someone else. //  

system.schedule('Job Name', s, m);

 

Thanks for your help. I have read over the tutorial in the Apex workbook and the Apex Scheduler in the documentation...but I still don't know where to put my system.schedule method or what "job name" means in my code.

 

Please help!

I have a query where I'm trying to return the chatter posts and comments that pertain to a specific set of sObject's that were previously queried:

List<sObject__c> items = [SELECT Id FROM sObject__c ...];

Map<Id,sObject__Feed> projectTaskFeeds = new Map<Id,Project_Task__Feed>([SELECT Id, Type, CreatedById, CreatedBy.FirstName, CreatedBy.LastName, ParentId, Parent.Name, Body, Title, LinkUrl, ContentData, ContentFileName, (SELECT Id, CommentBody, CreatedDate, CreatedBy.FirstName, CreatedBy.LastName FROM FeedComments)
 FROM sObject__Feed WHERE ParentId IN :items LIMIT 50000]);

 But the resulting map only contains the sObject__c feed items, and not the related FeedComments.

Map<Id,sObject__Feed> projectTaskFeeds = new Map<Id,Project_Task__Feed>([SELECT Id, Type, CreatedById, CreatedBy.FirstName, CreatedBy.LastName, ParentId, Parent.Name, Body, Title, LinkUrl, ContentData, ContentFileName, (SELECT Id, CommentBody, CreatedDate, CreatedBy.FirstName, CreatedBy.LastName FROM FeedComments)
 FROM sObject__Feed LIMIT 50000]);

 

 

If I don't use the limiting 'WHERE' Clause however, I get the comments as well (but I got all items that are in the sObject__Feed table, which could easily be more than 50000 results in a large org.

 

Am I doing something wrong?

I have the following trigger.

 

To summarize: when a record is inserted into the object of this trigger if there is a related parent record it looks up and sets 2 fields on that record.

 

trigger SetDJELFromDepreciationSchedule on Depreciation_Journal_Entry_Line__c (Before Insert) 
{      
     for(AcctSol__Depreciation_Journal_Entry_Line__c objDJEL : Trigger.new)    
     {      
        if (objDJEL.AcctSol__Depreciation_Schedule__c != null)
        {          
           AcctSol__Depreciation_Schedule__c TheDS = 
              [select AcctSol__Accum_Depr_GL_Acct__c, AcctSol__Depr_Exp_GL_Acct__c from         
              AcctSol__Depreciation_Schedule__c where Id  
              = :ObjDJEL.AcctSol__Depreciation_Schedule__c];                        
           if(objDJEL.AcctSol__Credit_GL_Account__c == null)          
           {              
            objDJEL.AcctSol__Credit_GL_Account__c = TheDS.AcctSol__Accum_Depr_GL_Acct__c;          
           }          

           if(objDJEL.AcctSol__Debit_GL_Account__c == null)          
           {              
            objDJEL.AcctSol__Debit_GL_Account__c = TheDS.AcctSol__Depr_Exp_GL_Acct__c;          
           }     
      }    
  } 
}

 This code was written back in May and I can confirm that it works. But now all of a sudden the Force.com Security Source Code scanner is rejecting it.

 

CWE ID 10540

This rule identifies Apex where SOQL (salesforce.com Object Query Language) or SOSL (salesforce.com Object Search

Language) statements are executed within a loop.

 

I would ask how this code passed a test a couple weeks ago and now fails but I guess I don't really care - 'tis not my business to understand the rules - just to obey them :-)

 

I was wondering if someone could show me the easiest way to solve this problem ?

(I have some theories but I am also very new at this so I want to check with someone with more experience)

 

Thanks in Advance for your Assistance,

AngiB

 

Hi all, I am newbie to Apex coding and need a help regarding this . I'm trying to execute this but its showing a strange problem.

 

The moment i access chkLead.Z_Sales_Office_Code__c the value becomes null. I've used debug statements to prove it, Here1 returns a value but Here 2 the value is null.

 

Is there any other way to achieve this ?

 

 

for(Lead chkLead :currentLeadList){
Decimal Flag=0;
//system.debug('Here 1--------'+salesRepUserIdMap.get(chkLead));
//chkLead.Z_Sales_Office_Code__c=salesRepUserIdMap.get(chkLead);
//system.debug('Here 2--------'+salesRepUserIdMap.get(chkLead));
for(Z_Sales_Office_Code_Default__c teamAssRec: teamAssignList){

if(salesRepUserIdMap.get(chkLead)==teamAssRec.name && teamAssRec.Z_Sales_Office_Type__c=='REN'){
if(chkLead.z_product_type__c=='Display'){
chkLead.OwnerId=displaySalesMap.get( salesRepUserIdMap.get(chkLead));
Flag=1;
}
else{
chkLead.OwnerId=semiSalesMap.get( salesRepUserIdMap.get(chkLead));
Flag=1;
}

}

 

 

 

Thanks a lot

Hi 

We have a approval process for Contracts approval.Can i just know where is this approval process residing.I checked the workflow and approval tab .Its not displayed there.I have to edit some steps in approval.Or if i can add a new approval process other than the existing(deleting previous one later on).How can i link the approval process to a contract.so that we know this approval process is for approving Contracts.Any help is greatly appreciated.

Thanks

Below oli trigger works fine but I am not comfortable having Opportunity query in a for loop. Any suggestions to write this code in a better way is much appreciated. 

 

trigger StatusChange on OpportunityLineItem (after update) {

List <Shipping_Status__c> new_status = new List<Shipping_Status__c>();

for(OpportunityLineItem oli : trigger.new)
{
Opportunity opp = [SELECT StageName FROM Opportunity WHERE Id = :oli.OpportunityId];
if (opp.StageName=='Win')
{
if (trigger.isUpdate)
{
if((oli.Stage__c <> trigger.oldMap.get(oli.Id).Stage__c))
{
Shipping_Status__c priorSS = [SELECT SS_New_Stage__c, CreatedDate FROM Shipping_Status__c WHERE SS_Line_Item_Id__c = :oli.id ORDER BY CreatedDate DESC LIMIT 1];
Shipping_Status__c s = new Shipping_Status__c();
s.SS_Line_Item_Id__c = oli.id;
s.SS_Opportunity__c = oli.OpportunityId;
s.SS_Product_Name__c = oli.Product_Short_Name__c;
s.SS_Prior_Stage__c = priorSS.SS_New_Stage__c;
s.SS_New_Stage__c = oli.Stage__c;
s.SS_Previous_Stage_Date__c = priorSS.CreatedDate;
new_status.add(s);
}
}
}

}
Insert new_status;
}

Hi All,

 

Here is my situation:

I have custom object with a trigger that updates a field in Contact. This trigger fires in insert, update & delete.

I also have a Contact trigger which updates this custom object (insert/delete) on certain conditions alone. The contact trigger also handles many other functionality, but each is executed only on certain condition.

The contact and custom object have master-child relationship. 1 contact can have many child custom objects.

 

On a particular condition, when a contact trigger insert or delete one of the child custom record, the recursion occurs which I want to stop.

To do this, I created a custom text field (source__c) in the custom object (custom__c) and updates the value of it (Ex: 'From Contact Trigger') in Contact trigger alone.

Now I want to exit from the Custom_Trigger without executing the rest of code when the custom__c.source__c == 'From Contact Trigger'

The break or continue statement wont work here. There is no exit() stmt. I also don't want to explicitly through error to the user since user.

 

I have developed a scheduled apex that does the same job as custom object trigger and run it once a day so the field value in contact updated.

So updating the contact field is taken care. But I want to avoid the exception which is preventing the custom record insert/delete during contact trigger.

 

Is there an elegant way to do this? Is there any method available in apex that substitute exit()?

 

Please help!

Thanks in advance!

Hello,

 

I am trying to plan out an integration with a third-party system and I need a sample XML for when a new record is created/updated in Salesforce (e.g. a new Account is created or a Contact record is updated). I know where to find the general XML schema but will need more than than just this. Is there a way to get a sample XML that I require?

 

Thanks for your help in advance.

I am trying to download a file attached to a chatter feed. Barring extensions and other naming issues, there is an interesting problem:

 

I get a fresh OAuth access token from the stored refresh token, but every time I try to download the file I get a 401 response containing

 

[{"message":"Session expired or invalid","errorCode":"INVALID_SESSION_ID"}]

 

Does anyone have had a similar issue? How can I unblock this? I have read the other messages regarding this but the proposed solutions (if any) do not work for me.

 

This is the command I use to download the file

 

curl -v https://na9.salesforce.com/services/data/v25.0/chatter/files/069E0000000UylDIAS/content -H "Authorization: OAuth xxDExxxxxxxxZCxx%21ARsAQGWxOZVEP.GemGLJ.PTYPGdVxcynRHBB9ExtYCxhgD1UJ6kFR_yVPqOofFZvLEmqxeXMtgXqBVxzvxGGqP_dAPxEvNlx"

 

(I've tried "Bearer" instead of "OAuth" in the auth header, as it's the word I use for the REST API, but the result is the same)

 

(some numbers and letters have been changed to "x" in the token, to protect it. It will expire in any case)

 

 

Thanks to everyone!