• David Berman
  • NEWBIE
  • 0 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 15
    Replies
Hi,
I'm hoping someone can help with my two issues:
1) I'm in Classic and I have an Environtment Hub member record that I've SSO-disabled. Now I want to re-enable it and I get a generic 'This operation failed' error. It used to have SSO enabled before.

2) I clicked the "Remove" button and the Environment Hub record disappeared, but there was also an FYI message about this record still existing, but in an inactive state.  How can I find this record?  I tried SOQL querying for records last modified today, I looked for those records with the Member Entity Id being the Salesforce Org's Company ID - no luck.
I'm connecting to Mavenlink to pull time cards  and running the below code in the Developer Console.  2/3s down the page my last if-statement block of code causes the code to fail without any explanation.  Commenting out that if-statement block causes a successful execution.

I hope someone can help..I hope it's a silly little thing I missed and I can stop banging my head in the wall....
 
httpRequest reqWorkspaces = new httpRequest();
reqWorkspaces.setMethod('GET');
reqWorkspaces.setEndpoint('https://api.mavenlink.com/api/v1/time_entries.json'+
                          '?created_after=2015-08-01T000000&created_before=2015-08-16T000000&page=1&per_page=20');
reqWorkspaces.setHeader('Authorization', 'Bearer xxxxxxxx');
reqWorkspaces.setTimeout(120000);
httpResponse resWorkspaces = new http().send(reqWorkspaces);

JSONParser parserCount = JSON.createParser(resWorkspaces.getBody());
Integer iCountTimecards = 0;
Integer iNumberOfBatches = 0;

while(parserCount.nextToken() != null)
{
	if((parserCount.getCurrentToken() == JSONToken.FIELD_NAME) && (parserCount.getText() == 'count'))
    {
        parserCount.nextToken();
        iCountTimecards = Integer.valueOf(parserCount.getText());
    }
}

SYSTEM.DEBUG('+++++ iCountTimecards: ' + iCountTimecards);

Map<String, String> mapKeyValue = new Map<String, String>();
Map<String, Map<String, String>> mapJSON = new Map<String, Map<String, String>>();

if(iCountTimecards > 0)
{
	iNumberOfBatches = Math.round(iCountTimecards / 200) + 1;
    
SYSTEM.DEBUG('+++++ iNumberOfBatches: ' + iNumberOfBatches);

	reqWorkspaces.setTimeout(120000);
    
	for(Integer iBatchNum = 1; iBatchNum <= iNumberOfBatches; iBatchNum++) 
    {

		reqWorkspaces.setEndpoint('https://api.mavenlink.com/api/v1/time_entries.json'+
                                  '?created_after=2015-08-01T000000&created_before=2015-16-01T000000&page=' + iBatchNum );
	
		resWorkspaces = new http().send(reqWorkspaces);
		
		JSONParser parser = JSON.createParser(resWorkspaces.getBody());
        
		String strTCID = '';
		String strProjectID = '';
		String strUserID = '';
		String strApproved = '';
		String strBillable = '';
		String strCreatedAt = ''; 
		String strUpdatedAt = '';
		String strDatePerformed = '';
		String strTimeInMinutes = '';
		String strRateInCents = '';
		String strNotes = '';
		String strStoryID = '';
        
		while(parser.nextToken() != null) 
		{
		    if(parser.getCurrentToken() == JSONToken.FIELD_NAME) 
		    {
                if(parser.getText() == 'created_at')
                {
                    parser.nextToken();
                    strCreatedAt = parser.getText();
                }
                
                if(parser.getText() == 'updated_at')
                {
                    parser.nextToken();
                    strUpdatedAt = parser.getText();
                }
                
                if(parser.getText() == 'date_performed')
                {
                    parser.nextToken();
                    strDatePerformed = parser.getText();
                }
                
                if(parser.getText() == 'time_in_minutes')
                {
                    parser.nextToken();
                    strTimeInMinutes = parser.getText();
                }
                
                if(parser.getText() == 'billable')
                {
                    parser.nextToken();
                    strBillable = parser.getText();
                }
                
                if(parser.getText() == 'notes')
                {
                    parser.nextToken();
                    strNotes = parser.getText();
                }
                
                if(parser.getText() == 'rate_in_cents')
                {
                    parser.nextToken();
                    strRateInCents = parser.getText();
                }
                
                if(parser.getText() == 'approved')
                {
                    parser.nextToken();
                    strApproved = parser.getText();
                }
                
                if(parser.getText() == 'story_id')
                {
                    parser.nextToken();
                    strStoryID = parser.getText();
                }
                
                if(parser.getText() == 'workspace_id')
                {
                    parser.nextToken();
		        	strProjectID = parser.getText();
                }
		        		    		    
                if(parser.getText() == 'user_id') 
                {
                    parser.nextToken();
                    strUserID = parser.getText();
                }
                
 // Commenting out the next 'if' block causes a successful execution... leaving it as is
 // causes an unknown failure
                
                if(parser.getText() == 'id')
                {
                    parser.nextToken();
                    strTCID = parser.getText();
                    
                    mapKeyValue.put('id', strTCID);
                    mapKeyValue.put('workspace_id', strProjectID);
                    mapKeyValue.put('created_at', strCreatedAt);
                    mapKeyValue.put('updated_at', strUpdatedAt);
                    mapKeyValue.put('date_performed', strDatePerformed);
                    mapKeyValue.put('time_in_minutes', strTimeInMinutes);
                    mapKeyValue.put('billable', strBillable);
                    mapKeyValue.put('notes', strNotes);
                    mapKeyValue.put('rate_in_cents', strRateInCents);
                    mapKeyValue.put('approved', strApproved);
                    mapKeyValue.put('story_id', strStoryID);
                    mapKeyValue.put('user_id', strUserID);
                    
                    mapJSON.put(strTCID, mapKeyValue);
                    mapKeyValue.clear();
                    
                }

                
            } // if(parser.getCurrentToken() == JSONToken.FIELD_NAME) 

		} // while(parser.nextToken() != null) 
        
	} // for(Integer iBatchNum = 1; iBatchNum <= iNumberOfBatches; iBatchNum++) 
} // if(iCountTimecards > 0)

 
If I had JSON that looked like this:
 { "user" : { "name" : "Simon Fell", "twitter" : "@superfell" } }, then I would set up a User class with the name and twitter properties.
In my case my JSON looks like this:
{"count":2,"users":
{"5599357":{"full_name":"Accounting","photo_path":"https://....s3.amazonaws.com/attachments/final/2015-06-09/5599357/2928b4_default","email_address":"accounting@acme.com","headline":"","account_id":"3473215","id":"5599357"},

"5752807":{"full_name":"JDoe","photo_path":"https://.../default.png","email_address":"jdoe@acme.com","headline":null,"account_id":"3783877","id":"5752807"}}}

The problem I'm facing is that the id (e.g. 5599357, 5752807) is repeated infront of the key/value pairs that follows.

Could someone suggest how I could parse out the information into a User class/object with attributes full_name, photo_path, email_address, headline, account_id and id?

By the way this is JSON returned from Mavenlink.
Thanks!


 
I have revenue scheduling enabled, so that I can calculate the daily revenue for opportunity line items for a given date range.

I would like to do a YoY report, to see the Q3 2014 (previous quarter) compared to the Q3 2013 (previous quarter, previous year).

With just opportunities, I can do this using the close date and this formula: If(PREVGROUPVAL(AMOUNT:SUM,CLOSE_DATE) >0, (AMOUNT:SUM - PREVGROUPVAL(AMOUNT:SUM,CLOSE_DATE)) / PREVGROUPVAL(AMOUNT:SUM, CLOSE_DATE), 0)

In my report filter I grab close dates that are either between 7/1/13 and 9/30/13 or 7/1/14 and 9/30/14.

With line item schedules I'm using the report type "Opportunities with Products and Schedules", but I can't figure out what the field name is for the Schedule Date (to use instead of CLOSE_DATE above). I tried ScheduleDate, Schedule_Date, FiscalScheduleDate, no luck..

I hope someone can help. Thanks!
How do I write a validation rule for a field with the following requirement: It gets checked by the user and as a result I need a second field to also be checked?  It seems too simple to use a dependent field.
I'm connecting to Mavenlink to pull time cards  and running the below code in the Developer Console.  2/3s down the page my last if-statement block of code causes the code to fail without any explanation.  Commenting out that if-statement block causes a successful execution.

I hope someone can help..I hope it's a silly little thing I missed and I can stop banging my head in the wall....
 
httpRequest reqWorkspaces = new httpRequest();
reqWorkspaces.setMethod('GET');
reqWorkspaces.setEndpoint('https://api.mavenlink.com/api/v1/time_entries.json'+
                          '?created_after=2015-08-01T000000&created_before=2015-08-16T000000&page=1&per_page=20');
reqWorkspaces.setHeader('Authorization', 'Bearer xxxxxxxx');
reqWorkspaces.setTimeout(120000);
httpResponse resWorkspaces = new http().send(reqWorkspaces);

JSONParser parserCount = JSON.createParser(resWorkspaces.getBody());
Integer iCountTimecards = 0;
Integer iNumberOfBatches = 0;

while(parserCount.nextToken() != null)
{
	if((parserCount.getCurrentToken() == JSONToken.FIELD_NAME) && (parserCount.getText() == 'count'))
    {
        parserCount.nextToken();
        iCountTimecards = Integer.valueOf(parserCount.getText());
    }
}

SYSTEM.DEBUG('+++++ iCountTimecards: ' + iCountTimecards);

Map<String, String> mapKeyValue = new Map<String, String>();
Map<String, Map<String, String>> mapJSON = new Map<String, Map<String, String>>();

if(iCountTimecards > 0)
{
	iNumberOfBatches = Math.round(iCountTimecards / 200) + 1;
    
SYSTEM.DEBUG('+++++ iNumberOfBatches: ' + iNumberOfBatches);

	reqWorkspaces.setTimeout(120000);
    
	for(Integer iBatchNum = 1; iBatchNum <= iNumberOfBatches; iBatchNum++) 
    {

		reqWorkspaces.setEndpoint('https://api.mavenlink.com/api/v1/time_entries.json'+
                                  '?created_after=2015-08-01T000000&created_before=2015-16-01T000000&page=' + iBatchNum );
	
		resWorkspaces = new http().send(reqWorkspaces);
		
		JSONParser parser = JSON.createParser(resWorkspaces.getBody());
        
		String strTCID = '';
		String strProjectID = '';
		String strUserID = '';
		String strApproved = '';
		String strBillable = '';
		String strCreatedAt = ''; 
		String strUpdatedAt = '';
		String strDatePerformed = '';
		String strTimeInMinutes = '';
		String strRateInCents = '';
		String strNotes = '';
		String strStoryID = '';
        
		while(parser.nextToken() != null) 
		{
		    if(parser.getCurrentToken() == JSONToken.FIELD_NAME) 
		    {
                if(parser.getText() == 'created_at')
                {
                    parser.nextToken();
                    strCreatedAt = parser.getText();
                }
                
                if(parser.getText() == 'updated_at')
                {
                    parser.nextToken();
                    strUpdatedAt = parser.getText();
                }
                
                if(parser.getText() == 'date_performed')
                {
                    parser.nextToken();
                    strDatePerformed = parser.getText();
                }
                
                if(parser.getText() == 'time_in_minutes')
                {
                    parser.nextToken();
                    strTimeInMinutes = parser.getText();
                }
                
                if(parser.getText() == 'billable')
                {
                    parser.nextToken();
                    strBillable = parser.getText();
                }
                
                if(parser.getText() == 'notes')
                {
                    parser.nextToken();
                    strNotes = parser.getText();
                }
                
                if(parser.getText() == 'rate_in_cents')
                {
                    parser.nextToken();
                    strRateInCents = parser.getText();
                }
                
                if(parser.getText() == 'approved')
                {
                    parser.nextToken();
                    strApproved = parser.getText();
                }
                
                if(parser.getText() == 'story_id')
                {
                    parser.nextToken();
                    strStoryID = parser.getText();
                }
                
                if(parser.getText() == 'workspace_id')
                {
                    parser.nextToken();
		        	strProjectID = parser.getText();
                }
		        		    		    
                if(parser.getText() == 'user_id') 
                {
                    parser.nextToken();
                    strUserID = parser.getText();
                }
                
 // Commenting out the next 'if' block causes a successful execution... leaving it as is
 // causes an unknown failure
                
                if(parser.getText() == 'id')
                {
                    parser.nextToken();
                    strTCID = parser.getText();
                    
                    mapKeyValue.put('id', strTCID);
                    mapKeyValue.put('workspace_id', strProjectID);
                    mapKeyValue.put('created_at', strCreatedAt);
                    mapKeyValue.put('updated_at', strUpdatedAt);
                    mapKeyValue.put('date_performed', strDatePerformed);
                    mapKeyValue.put('time_in_minutes', strTimeInMinutes);
                    mapKeyValue.put('billable', strBillable);
                    mapKeyValue.put('notes', strNotes);
                    mapKeyValue.put('rate_in_cents', strRateInCents);
                    mapKeyValue.put('approved', strApproved);
                    mapKeyValue.put('story_id', strStoryID);
                    mapKeyValue.put('user_id', strUserID);
                    
                    mapJSON.put(strTCID, mapKeyValue);
                    mapKeyValue.clear();
                    
                }

                
            } // if(parser.getCurrentToken() == JSONToken.FIELD_NAME) 

		} // while(parser.nextToken() != null) 
        
	} // for(Integer iBatchNum = 1; iBatchNum <= iNumberOfBatches; iBatchNum++) 
} // if(iCountTimecards > 0)

 
If I had JSON that looked like this:
 { "user" : { "name" : "Simon Fell", "twitter" : "@superfell" } }, then I would set up a User class with the name and twitter properties.
In my case my JSON looks like this:
{"count":2,"users":
{"5599357":{"full_name":"Accounting","photo_path":"https://....s3.amazonaws.com/attachments/final/2015-06-09/5599357/2928b4_default","email_address":"accounting@acme.com","headline":"","account_id":"3473215","id":"5599357"},

"5752807":{"full_name":"JDoe","photo_path":"https://.../default.png","email_address":"jdoe@acme.com","headline":null,"account_id":"3783877","id":"5752807"}}}

The problem I'm facing is that the id (e.g. 5599357, 5752807) is repeated infront of the key/value pairs that follows.

Could someone suggest how I could parse out the information into a User class/object with attributes full_name, photo_path, email_address, headline, account_id and id?

By the way this is JSON returned from Mavenlink.
Thanks!


 
I have revenue scheduling enabled, so that I can calculate the daily revenue for opportunity line items for a given date range.

I would like to do a YoY report, to see the Q3 2014 (previous quarter) compared to the Q3 2013 (previous quarter, previous year).

With just opportunities, I can do this using the close date and this formula: If(PREVGROUPVAL(AMOUNT:SUM,CLOSE_DATE) >0, (AMOUNT:SUM - PREVGROUPVAL(AMOUNT:SUM,CLOSE_DATE)) / PREVGROUPVAL(AMOUNT:SUM, CLOSE_DATE), 0)

In my report filter I grab close dates that are either between 7/1/13 and 9/30/13 or 7/1/14 and 9/30/14.

With line item schedules I'm using the report type "Opportunities with Products and Schedules", but I can't figure out what the field name is for the Schedule Date (to use instead of CLOSE_DATE above). I tried ScheduleDate, Schedule_Date, FiscalScheduleDate, no luck..

I hope someone can help. Thanks!
Hi,

I am new to salesforce. while trying to access my map value, i am getting the exception like

System.NullPointerException: Attempt to de-reference a null object

My  declaration is like
map<ID,Customobj> mymap =new map<ID,Customobj> ();
ID is a custom object ID ( which is a lookup field in Customobj)
after putting the value, i can see the map size is 1

Customobj  obj = new Customobj();

i am trying to access the map value by providing the ID
obj =mymap.get(ID);  ==>verified ID is valid one

now trying to access the field of this object
obj.fieldname ====> getting Null pointer exception


Please advice
hello

i am trying to make a validation rule for a currency field with 2 decimal values so that it only enables the user to put .00 .25 .50 and .75, with any other value in the decimals i need it to trigger the erro message.
this is what i've got so far:

NOT(REGEX(TEXT( Gross_Pay__c ), "[0-9]+[.]{1}[25,50]{2}")) it works for 25 and other values but not for 50 
Hello,

I am trying to rollup some information in Salesforce. How would I rollup a field on the account level with number of active users (users with a last activity date within the last 12 months)? I tried this using a free version o rollup helper but it doesn't seem to be working correctly. Any ideas?
We're trying to create an account field which displays the last activity date for activities created by the account owner. Has anyone found a way to do this?

Thank you,
Tyler
I'm trying to use a CASE field to look up the first two characters of a postcode and output some broad regions that we use to report on data. So far i have this:
CASE( UPPER(LEFT(BillingPostalCode,2)),
'PL', "South West England",
'PO', "South West England"

/*TONNES OF OTHERS */
        "Unfound"
 )

Obviously once i get all the UK postcodes in there, it exceeds the character limit, plus it just looks horribly clumsy. I've tried things like
'PL' : 'PO', "South West England"  
to shorten the formula, but i can't seem to make any of them work. Is there any more elegant way of pointing those multiple options at a single result? 

Apologies if this has been tackled elsewhere, i had a good look round the forums and couldn't find anything that seemed to solve it.
I've written a trigger where a notification in form of an email is sent to the  Owner when the Lead Status field is changed .But the requirement was different and i did it to send email to the Owner which is not.

 A help in Trigger where the requirement is that, an email should be sent from the Owner to the particular Lead Please help me to achieve this..Below is the code.

Really appreciate the help.
trigger UpdateLeadStatus on Lead (after update) {
    Map <Id, String> leadsOwner = new Map <Id, String> ();

    // Go through every lead in the trigger
    for (Lead lead : trigger.new)
    {
        // Check if the status has been changed
        if (lead.Status != trigger.oldMap.get(lead.Id).Status)
        {
            // get the owner ID's that have been affected
            leadsOwner.put(lead.ownerId, null);
        }
    }

    // Map the owner ID to it's email address
    for (User owner : [SELECT Id, Email FROM User WHERE Id = :leadsOwner.keySet()])
    {
        leadsOwner.put(owner.Id, owner.Email);
    }

    List <Messaging.SingleEMailMessage> emails = new List <Messaging.SingleEMailMessage> ();

    // Go again through every lead in the trigger
    for (Lead lead : trigger.new)
    {   
        // Only work with leads that have owners mapped to their email addresses (only those ones have their status changed)
        if (leadsOwner.get(lead.OwnerId) != null)
        {
            // Create an email message and add it to the list
            Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage(); 
            List <String> toAddresses = new List <String> {leadsOwner.get(lead.OwnerId)};
            mail.setToAddresses(toAddresses); 
            mail.setSubject('Automated Email : Lead Status Updated'); 
            String body = 'The status has been changed on the lead record with ID ' + lead.Id; 
            mail.setPlainTextBody(body); 
            emails.add(mail);
        }
    }
    Messaging.sendEmail(emails);
}


Hey everyone,

 

I'm trying to get a validation rule that emails the user whenever a record is created or edited, unless it happens to be on either of two fields. I'm still occasionally getting emails when I'm sure these fields are the only thing getting updated. I've selected "Run this rule if the following formula evaluates to true"

 

I want all fields to cause an email to be sent except when Most_Recent_Email__c or Most_Recent_Good_Lead__c are updated.

 

AND(
PRIORVALUE(Most_Recent_Email__c) = Most_Recent_Email__c,
PRIORVALUE(Most_Recent_Good_Lead__c) =Most_Recent_Good_Lead__c
)

  • June 06, 2012
  • Like
  • 0

Hi,

The documentation leads me to "salesforce" to obtain keys for OAuth identification in REST API, does anyone know where I can find or request it?

We have a trigger on Task that has been working fine for over a year. Recently, an admin tried to add a number of recurring Tasks via the data loader and received the error message "UNSUPPORTED_APEX_TRIGGER_OPERATION:Apex Task trigger cannot handle batch operations on recurring tasks."

 

I thought I could update the trigger to check for recurring tasks but that still doesn't resolve the problem. Has anyone come across this error and, if so, how did you resolve it?

-greg

  • January 13, 2010
  • Like
  • 0