• Rocket
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 7
    Questions
  • 26
    Replies

Hi,

 

I have field on the object in which users have to enter Time and date manually.Now we want to replace that field with date and time field so that instead of typing  date and time manualy they can select date and time.

 

If we delete this field

 

1) What will happen to the existing data associated to the field.

 

What do you think are my options?What are your sugestions?.How Shall I proceed.

 

Please advise.

Thanks

 

  • August 19, 2013
  • Like
  • 0

Hi,

 

I am the admin of the system .Whenever I want to make changes to anything related to particular user in the system I goto setup,Manage users and Users and then click on the login link beside the user name and then I can make changes for that user as I am logged in as that user.Now, I have one user for whom I do not see that login link so how do I make changes to that user.How do I login as that user.Any help will be appreciated.

 

Hi,

 

I am the admin of the system .Whenever I want to make changes to anything related to particular user in the system I goto setup,Manage users and Users and then click on the login link beside the user name and then I can make changes for that user as I am logged in as that user.Now, I have one user for whom I do not see that login link so how do I make changes to that user.How do I login as that user.Any help will be appreciated.

 

 

Hi Friends,

 

I have simple jquery and I am only using Html page and not any visual force page.I am trying to figure out why addclass fucntion is not firing when  the document get's loaded.I was expecting that css will be applied to the paragraph tag when the script gets executed.That is not happening.I tried putting alert in the same section before and after addclass method and I can see that alert getting executed so it means docoument.getready function is getting executed but addclass is not executing.Can somebody please help?

 

<!DOCTYPE html>

<html>
<head>
<style>
.highlight
{
font-weight:bold;
font-size:xx-large;
background-color:green;
}
</style>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js">
</script>
<script>
$(document).ready(function()
{

alert('Yes');
$('p').addclass('highlight');
alert('great');
</script>
</head>
<body>
<h1>Heading 1</h1>
<h2>Heading 2</h2>
<p>This is a paragraph.</p>
<p>This is another paragraph.</p>
<div>This is some important text!</div>
</body>
</html>

  • April 20, 2013
  • Like
  • 0

Hi Friends,

 

Cookbook contains just cookbook recipes or it has something more in it.Can somebody answer? I am asking becasue I am not able to download as it gives me an error.  

 

 

The Force.com Cookbook downloadable book

  • April 15, 2013
  • Like
  • 0

Hi Friends,

 

Since we are working on analytics outside our salesforce system.Therefore,we have to read data from salesforce and use it outsifde salesforce to create analytics .

 

My Question:-Outside vendor has to get into salesforce and read data from it.Can somebody tell me steps on how to go about it.

My idea is that outside vendor has to login to salesforce.In order to accomplish that.

Do I need to.

 

1)Give  enterpriswe url or partner url to them   

3) So once they have been able to log in to the salesforce then how are they going to read data or pull out data from salesforce.Are there any API'S which they have to use to read data from salesforce? 

 

Guys, please suggests. 

 

Thanks

 

 

 

  • April 15, 2013
  • Like
  • 0

Hi friends,

 

I am trying to calculate related closed won opportunities on the account object.For example,account1 has 5 opportunities.I want to show that number on the account object.

When I debug I see null value in the statement .Don't know why

 

System.debug('the value in the zero variabke of a.zero is'+a.add(zero)); 

 

Can somebody help by either correcting it or suggesting better solution .

 

 

 

 

 

 

 

trigger status1 on Account (before insert,before update)
{
 
List<Account> accountWithOpptys = [select id, name,WonOpportunitiesRelatedToThisAccount__c, (select id, name, closedate, stagename from Opportunities  where accountId IN :Trigger.newMap.keySet()and StageName = 'Closed Won')from Account where Id IN :Trigger.newMap.keySet()];


list<account>l=new list<account>();
list<opportunity>a=new list<opportunity>();
    for(account app:accountWithOpptys)
        {
        for(opportunity zero: app.opportunities)
         {
         System.debug('Tasjdshjshdjshdsbefore is statement ');
        if(zero.stagename=='Closed Won')
            {
                a.add(zero);
                  
                System.debug('the value in the zero variabke of a.zero is'+a.add(zero)); 
                   
                   
               System.debug('this is in sdie for loop with the value in the zero.stagenemnt');
                //l.add(ask);                       
                if(a.size()>0)
                {
                
                app.WonOpportunitiesRelatedToThisAccount__c=l.size();
                
                
             
                
                }
                
            }
            
}
}
}

  • April 07, 2013
  • Like
  • 0

Hi I wrote a web service client in apex and my service is running some where in AWS. When I execute this client I am getting an error like this.

 

 

 

04:30:53.898 (898029000)|EXCEPTION_THROWN|[55]|System.CalloutException: Web service callout failed: Failed to get next element
04:30:53.898 (898227000)|HEAP_ALLOCATE|[55]|Bytes:58
04:30:53.898 (898255000)|SYSTEM_METHOD_EXIT|[55]|WebServiceCallout.invoke(APEX_OBJECT, APEX_OBJECT, MAP, LIST)
04:30:53.898 (898281000)|METHOD_EXIT|[89]|01p90000002PtQQ|DpaaSSoapWebService.DataProtectionWebServiceImplPort.tokenize(String, String, LIST<DpaaSSoapWebService.Field>)
04:30:53.898 (898338000)|VARIABLE_SCOPE_BEGIN|[95]|e|Exception|true|false
04:30:53.898 (898493000)|VARIABLE_ASSIGNMENT|[95]|e|"common.apex.runtime.impl.ExecutionException: Web service callout failed: Failed to get next element"|0x7ba0f658
04:30:53.898 (898512000)|STATEMENT_EXECUTE|[95]
04:30:53.898 (898518000)|STATEMENT_EXECUTE|[96]
04:30:53.898 (898561000)|METHOD_ENTRY|[96]|01p90000002PtQS|DpaasWebServiceClient.__sfdc_render(Boolean)
04:30:53.898 (898709000)|VARIABLE_ASSIGNMENT|[-1]|this|{"detokenizedTokens":"0xe69935d","dpaasDecryptedFieldV (5 more) ...":"0x3549c60f","dpaasEncryptedFieldV (5 more) ...":"0x7e6a1e1d","dpaasFieldVoList":"0x4c74b89f","dpaasSoapWebService":"0x68df42c1","errors":"0x48507f95","isError":false,"render":true,"resultedFields":"0x1997c2b1","status":""}|0x51a1a957
04:30:53.898 (898734000)|HEAP_ALLOCATE|[11]|Bytes:5
04:30:53.898 (898757000)|VARIABLE_ASSIGNMENT|[-1]|value|false
04:30:53.898 (898771000)|HEAP_ALLOCATE|[11]|Bytes:5
04:30:53.898 (898800000)|VARIABLE_ASSIGNMENT|[11]|this.render|false|0x51a1a957
04:30:53.898 (898819000)|METHOD_EXIT|[96]|01p90000002PtQS|DpaasWebServiceClient.__sfdc_render(Boolean)
04:30:53.898 (898829000)|STATEMENT_EXECUTE|[97]
04:30:53.898 (898863000)|METHOD_ENTRY|[97]|01p90000002PtQS|DpaasWebServiceClient.__sfdc_isError(Boolean)
04:30:53.898 (898961000)|VARIABLE_ASSIGNMENT|[-1]|this|{"detokenizedTokens":"0xe69935d","dpaasDecryptedFieldV (5 more) ...":"0x3549c60f","dpaasEncryptedFieldV (5 more) ...":"0x7e6a1e1d","dpaasFieldVoList":"0x4c74b89f","dpaasSoapWebService":"0x68df42c1","errors":"0x48507f95","isError":false,"render":false,"resultedFields":"0x1997c2b1","status":""}|0x51a1a957
04:30:53.898 (898981000)|HEAP_ALLOCATE|[10]|Bytes:5
04:30:53.899 (899004000)|VARIABLE_ASSIGNMENT|[-1]|value|true
04:30:53.899 (899021000)|HEAP_ALLOCATE|[10]|Bytes:5
04:30:53.899 (899047000)|VARIABLE_ASSIGNMENT|[10]|this.isError|true|0x51a1a957
04:30:53.899 (899069000)|METHOD_EXIT|[97]|01p90000002PtQS|DpaasWebServiceClient.__sfdc_isError(Boolean)
04:30:53.899 (899080000)|STATEMENT_EXECUTE|[98]
04:30:53.899 (899107000)|SYSTEM_METHOD_ENTRY|[98]|System.CalloutException.getMessage()
04:30:53.899 (899145000)|HEAP_ALLOCATE|[98]|Bytes:54
04:30:53.899 (899161000)|SYSTEM_METHOD_EXIT|[98]|System.CalloutException.getMessage()
04:30:53.899 (899193000)|METHOD_ENTRY|[98]|01p90000002PtQS|DpaasWebServiceClient.__sfdc_status(String)
04:30:53.899 (899282000)|VARIABLE_ASSIGNMENT|[-1]|this|{"detokenizedTokens":"0xe69935d","dpaasDecryptedFieldV (5 more) ...":"0x3549c60f","dpaasEncryptedFieldV (5 more) ...":"0x7e6a1e1d","dpaasFieldVoList":"0x4c74b89f","dpaasSoapWebService":"0x68df42c1","errors":"0x48507f95","isError":true,"render":false,"resultedFields":"0x1997c2b1","status":""}|0x51a1a957
04:30:53.899 (899315000)|VARIABLE_ASSIGNMENT|[-1]|value|"Web service callout (34 more) ..."
04:30:53.899 (899345000)|VARIABLE_ASSIGNMENT|[9]|this.status|"Web service callout (34 more) ..."|0x51a1a957
04:30:53.899 (899360000)|METHOD_EXIT|[98]|01p90000002PtQS|DpaasWebServiceClient.__sfdc_status(String)
04:30:53.899 (899368000)|STATEMENT_EXECUTE|[101]
04:30:53.899 (899384000)|HEAP_ALLOCATE|[101]|Bytes:28
04:30:53.899 (899447000)|METHOD_EXIT|[168]|01p90000002PtQS|DpaasWebServiceClient.tokenize()
04:30:53.902 (902294000)|CODE_UNIT_FINISHED|DpaasWebServiceClient invoke(tokenizationStep2)
04:30:53.903 (903327000)|VF_APEX_CALL|j_id11|{!tokenizationStep2}|PageReference:/apex/dpaastokenizationstep2
04:30:53.913 (913159000)|CODE_UNIT_STARTED|[EXTERNAL]|01p90000002PtQS|DpaasWebServiceClient get(isError)
04:30:53.913 (913186000)|SYSTEM_MODE_ENTER|true
04:30:53.913 (913202000)|CODE_UNIT_STARTED|[EXTERNAL]|01p90000002PtQS|isError
04:30:53.913 (913222000)|CODE_UNIT_FINISHED|isError
04:30:53.913 (913232000)|CODE_UNIT_FINISHED|DpaasWebServiceClient get(isError)
04:30:53.913 (913357000)|CODE_UNIT_STARTED|[EXTERNAL]|01p90000002PtQS|DpaasWebServiceClient get(render)
04:30:53.913 (913371000)|SYSTEM_MODE_ENTER|true
04:30:53.913 (913382000)|CODE_UNIT_STARTED|[EXTERNAL]|01p90000002PtQS|render
04:30:53.913 (913394000)|CODE_UNIT_FINISHED|render
04:30:53.913 (913403000)|CODE_UNIT_FINISHED|DpaasWebServiceClient get(render)
04:30:53.932 (932203000)|CODE_UNIT_STARTED|[EXTERNAL]|01p90000002PtQS|DpaasWebServiceClient get(resultStatus)
04:30:53.932 (932234000)|SYSTEM_MODE_ENTER|true
04:30:53.932 (932249000)|CODE_UNIT_STARTED|[EXTERNAL]|01p90000002PtQS|resultStatus
04:30:53.932 (932271000)|CODE_UNIT_FINISHED|resultStatus
04:30:53.932 (932281000)|CODE_UNIT_FINISHED|DpaasWebServiceClient get(resultStatus)
04:30:53.932 (932523000)|CODE_UNIT_STARTED|[EXTERNAL]|01p90000002PtQS|DpaasWebServiceClient get(status)
04:30:53.932 (932537000)|SYSTEM_MODE_ENTER|true
04:30:53.932 (932548000)|CODE_UNIT_STARTED|[EXTERNAL]|01p90000002PtQS|status
04:30:53.932 (932564000)|CODE_UNIT_FINISHED|status
04:30:53.932 (932573000)|CODE_UNIT_FINISHED|DpaasWebServiceClient get(status)
04:30:53.934 (934364000)|VF_SERIALIZE_VIEWSTATE_BEGIN|06690000002Jzuy
04:30:53.936 (936594000)|VF_SERIALIZE_VIEWSTATE_END
04:30:54.593 (939789000)|CUMULATIVE_LIMIT_USAGE
04:30:54.593|LIMIT_USAGE_FOR_NS|(default)|
Number of SOQL queries: 0 out of 100
Number of query rows: 0 out of 50000
Number of SOSL queries: 0 out of 20
Number of DML statements: 0 out of 150
Number of DML rows: 0 out of 10000
Number of code statements: 60 out of 200000
Maximum heap size: 0 out of 6000000
Number of callouts: 1 out of 10
Number of Email Invocations: 0 out of 10
Number of fields describes: 0 out of 100
Number of record type describes: 0 out of 100
Number of child relationships describes: 0 out of 100
Number of picklist describes: 0 out of 100
Number of future calls: 0 out of 10

04:30:54.593|CUMULATIVE_LIMIT_USAGE_END

04:30:53.939 (939831000)|CODE_UNIT_FINISHED|VF: /apex/dpaasTokenizationStep1
04:30:53.939 (939841000)|EXECUTION_FINISHED

 

I observed the logs from developer console in that I was able to see the SOAP Response after that it showing like this in developer console.

 

I stuck over here. Can any one help me on this. Its a crtical for me. Plz

 

Thanks in advance

AravindCC

I modified an existing trigger on assets to also update the account team if a custom field on the asset has a value of 1. The trigger works as expected when I test it in the Sandbox however, it fails with too many SOQL queries when I execute the Test Class. The line it's failing on isn't inside of a for loop and should only be returning one record.  Can someone please explain what I've done wrong?

 

The trigger is failing on this line:

        // get the assignment group id for the VersaDoc Project Managers group   
        list<Assignment_Group_Name__c> asgnGroupNameIDs = [SELECT Id FROM Assignment_Group_Name__c WHERE Name = 'Support - VersaDoc Project Managers' limit 1];

Here's my trigger:

trigger trgAsset on Asset (after insert, after update, after delete) {
	if (trigger.isInsert || trigger.isUpdate){
		/*Trigger will update the Client_Since__c field on the account with the first purchase date for all assets.
		  If the Asset has VersaDoc and the account doesn't have a VersaDoc Project Account Team Member, 
		  it will assign the next VersaDoc Project manager from the assignment groups to the Account Team.*/
		// create a set of all the unique accountIds
		Set<id> accountIds= new Set<id>();
		Set<id> accountTeamAccountIds = new Set<id>(); // set of accountIDs that have VersaDoc in the asset
	    for (Asset a : Trigger.new){
	    	accountIds.add(a.AccountId); 
	    	if (a.HasVersadoc__c == 1 || a.HasVersadocStudio__c == 1 ) {
        		accountTeamAccountIds.add(a.AccountId); 
       	 	} 	
	    }
		   
		// create map of accountids and minimum purchase date
		map<ID, Date> acctSinceDate = new map<ID, Date>();	
	    AggregateResult[] groupedResults = [Select AccountId, MIN(PurchaseDate) MinPurchaseDate From Asset where AccountID in :accountIds GROUP BY AccountId];
		for (AggregateResult ar : groupedResults)  {
		    acctSinceDate.put(String.valueof(ar.get('AccountId')), Date.valueof(ar.get('MinPurchaseDate')) );
		}   	
		// create a map of accounts to update
		map<String, Account> accts = new map<String, Account>([Select Id, Client_Since__c from Account Where Id in :acctSinceDate.keySet()]);
		// update Account ClientSince field with MinimumPurchaseDate value
		//iterate over the list of accounts and assign the ClientSince date
		for (Account acct : accts.values()){
			acct.Client_Since__c = acctSinceDate.get(acct.Id);
		} 
		 if (accts.size()>0)
	        update(accts.values());
	        
		// get the assignment group id for the VersaDoc Project Managers group   
		list<Assignment_Group_Name__c> asgnGroupNameIDs = [SELECT Id FROM Assignment_Group_Name__c WHERE Name = 'Support - VersaDoc Project Managers' limit 1];
		
		Assignment_Groups__c[] asgnGroups = new List<Assignment_Groups__c>([SELECT Group_Name__c, User__c, Last_Assignment__c, Millisecond__c 
	                                   FROM Assignment_Groups__c 
	                                   WHERE Group_Name__c in :asgnGroupNameIds
	                                   AND Active__c = 'True' AND User_Active__c = 'True'
	                                   ORDER BY Last_Assignment__c, Millisecond__c] );                                    		
		Integer groupCount = asgnGroups.size();		
	    if (asgnGroups.isEmpty()) return;      

		//loop through list of accounts and get the accounts w/o VersaDoc Project Manager
		AccountTeamMember[] NewMembers = new AccountTeamMember[]{};  //list of new team members to add
	    AccountShare[] newShare = new AccountShare[]{};  //list of new shares to add
		Map<id, Account> acctsToUpdate = new Map<id, Account>([Select a.Id, (Select Id, AccountId From AccountTeamMembers WHERE TeamMemberRole = 'VersaDoc Project Manager' limit 1) From Account a Where a.Id in :accountTeamAccountIds]);
		Integer cnt = 0;
	    for (Account a : acctsToUpdate.values()){
	    	if (a.AccountTeamMembers == null || a.AccountTeamMembers.isEmpty()) {
	    		AccountTeamMember TeamMemberAd=new AccountTeamMember();
		        TeamMemberAd.AccountId=a.id;
		        TeamMemberAd.UserId=asgnGroups[cnt].User__c;
		       	TeamMemberAd.TeamMemberRole = 'VersaDoc Project Manager';
		        NewMembers.add(TeamMemberAd);	
		        datetime now = datetime.now();
		        asgnGroups.get(cnt).Last_Assignment__c=now;
		        asgnGroups.get(cnt).Millisecond__c = now.millisecondGMT(); 
	    		cnt ++;
	    		if (cnt == groupCount){ cnt = 0;}    	
	    	}
	    } 

		//insert any valid members then add their share entry if they were successfully added
	    Database.SaveResult[] lsr = Database.insert(NewMembers,false);
		Integer newcnt=0;
	    for(Database.SaveResult sr:lsr){
			if(!sr.isSuccess()){
				Database.Error emsg = sr.getErrors()[0];
				system.debug('\n\nERROR ADDING TEAM MEMBER:'+emsg);
			}else{
				newShare.add(new AccountShare(UserOrGroupId=NewMembers[newcnt].UserId, AccountId=NewMembers[newcnt].Accountid, AccountAccessLevel='Edit',OpportunityAccessLevel='Edit'));
			}
				newcnt++;			
	    }
	    //insert the new shares
	    Database.SaveResult[] lsr0 =Database.insert(newShare,false); 
	    Integer newcnt0=0;
	    for(Database.SaveResult sr0:lsr0){
			if(!sr0.isSuccess()){
				Database.Error emsg0=sr0.getErrors()[0];
			    system.debug('\n\nERROR ADDING SHARING:'+newShare[newcnt0]+'::'+emsg0);
			}
				newcnt0++;
	    } 
	    // update assignment groups with their LastAssignmentDate
	    update asgnGroups; 	                   	                     
	} else if (trigger.isDelete){
		// create a set of all the unique accountIds
		Set<id> accountIds = new Set<id>();
	    for (Asset a : Trigger.old)
	    	accountIds.add(a.AccountId); 	
		   
		// create map of accountids and minimum purchase date
		map<ID, Date> acctSinceDate = new map<ID, Date>();
		
	    AggregateResult[] groupedResults = [Select AccountId, MIN(PurchaseDate) MinPurchaseDate From Asset where AccountID in :accountIds GROUP BY AccountId];
		for (AggregateResult ar : groupedResults)  {
		    acctSinceDate.put(String.valueof(ar.get('AccountId')), Date.valueof(ar.get('MinPurchaseDate')) );
		} 
		// create a map of accounts to update 
		map<string, Account> accts = new map <string, Account>([Select Id, Client_Since__c from Account Where Id in :accountIds]);
		for (Account acct : accts.values()){
			// if there's a value in the acctSinceDate map, update the Client_Since__c date to that date, otherwise set to null.
			if(acctSinceDate.ContainsKey(acct.Id)){
				acct.Client_Since__c = acctSinceDate.get(acct.Id); 
			}else {
				acct.Client_Since__c = null;
			} 
		}
		update(accts.values());
	}
}

 Here's my test class:

 

@isTest
private class testTrgAsset {
	static testMethod void myUnitTest() {
		// create user to run the test as
	    Profile p = [select Id from profile where name = 'Standard User'];
	    UserRole r = [select Id from userrole where name = 'Sales Assistant'];
	       
	    User u = new User(lastname='testing', alias='test123', email='testing123@noemail.com',
	    	username='testing123@noemail.com', profileid = p.Id, userroleid = r.id,
	       	emailencodingkey='utf-8', Office_Code__c='US0000', LanguageLocaleKey='en_US',
	       	localesidkey='en_US', timezonesidkey='America/Los_Angeles');
	    insert u;	
	    
	    System.runAs(u) {  
		   	// Switch to the runtime 
		   	Test.StartTest(); 
		   		performCreateAssignmentGroups(u.Id, p.Id, r.id);
		       	performCreateAccounts(u.Id);   		   		
				performCreateAssets(u.Id);  
				performCreateAdditionalAssets(u.Id);
				performUpdateOriginalPurchaseDate(u.Id);
				performDeleteAssets(u.Id);
				performCreateVersaDocAssets(u.Id);	
		  	Test.StopTest();   
	     }
	}
	
	public static void performCreateAssignmentGroups(string createdby, string profileid, string userrole){
		integer i=0;
		List<User> users = new list<User>();
		for (i=0; i<3; i++){
			User u = new User(
			lastname = 'testing'+i,
			alias='test'+i,
			email='testing'+i+'@noemail.com',
			username='testing'+i+'@noemail.com',
			emailencodingkey='utf-8',
			Office_Code__c = 'US000',
			profileid = profileid,
			userroleid = userrole,
			LanguageLocaleKey='en_US',
			localesidkey='en_US', 
			timezonesidkey='America/Los_Angeles',
			IsActive=true);
			users.add(u);
		}
		insert users;
		
		//create an assignment group name
		Assignment_Group_Name__c agn = new Assignment_Group_Name__c(Name = 'Support - VersaDoc Project Managers');
		insert agn;
		
		Assignment_Groups__c[] NewMembers = new Assignment_Groups__c[]{};  //list of new assignmentgroup members to add
			
		for (User u : users){
			datetime now = datetime.now(); 
			Assignment_Groups__c a = new Assignment_Groups__c(
				Group_Name__c=agn.Id,
				User__c = u.Id,
				Active__c = 'true',
				Last_Assignment__c= now);
			NewMembers.add(a);
		}
		insert NewMembers;			
	}
	
	public static void performCreateAccounts(string createdby){
		list<Account> accts = new list<Account>();	
		User u = [select Id from User where Id =: createdby];
		integer i = 0;
	    // create 200 accounts
	    for (i=0; i < 200; i++ ){
	    	Account acc = new Account(
	    		Name='Testing Account ' +i, 
	    		Industry='Printers', 
	    		Type = 'Client',
	    		CreatedBy = u);
	    	accts.add(acc);
	    }	
	    insert accts;
	}

	public static void performCreateAssets(string createdby){
		list<Asset> assts = new list<Asset>();
		list<Account> accts = new list<Account>([Select id from Account where CreatedById =: createdby]);
		Product2 prod = [select Id from Product2 where Name = 'PrinterPresence Silver Level'];
		date now = date.today();
	   
	    // create an asset for each account
		for (Account acct : accts ){
			Asset a = new Asset(
	   			Product2 = prod,
	   			Name = 'PrinterPresence Silver Level',
	   			AccountID = acct.Id,
	   			Status = 'Purchased',
	   			PurchaseDate = now,
	   			RMR__c = 160.00, 
	   			Price = 2000.00);
	   		assts.add(a);	 
		}
	    insert assts;
	    
	      //check results of accounts to be sure ClientSince date was updated to the PurchaseDate
		 list <Account> accs = [Select Id, Client_Since__c from Account Where CreatedById =: createdby];
		 for (Account a : accs){
		 	System.assertEquals(now, a.Client_Since__c);   
		 }  
	}
	
	public static void performCreateAdditionalAssets(string createdby){
		list<Asset> assts = new list<Asset>();
		list<Account> accts = new list<Account>([Select id from Account where CreatedById =: createdby]);		
	 	list <Asset> insertedAsst = [Select Id from Asset where CreatedbyId =: createdby];		
		Product2 prod = [select Id from Product2 where Name = 'PrinterPresence Gold Level'];
		date now = date.today();
		
		//update previous asset to Attritioned-Upgrade
		for (Asset ass : insertedAsst){
			ass.Status = 'Attritioned-Upgrade';
			ass.UsageEndDate = System.today();
		}		
		update insertedAsst;
			   
	    // create an asset for each account
		for (Account acct : accts ){
			Asset a = new Asset(
	   			Product2 = prod,
	   			Name = 'PrinterPresence Gold Level',
	   			AccountID = acct.Id,
	   			Status = 'Purchased-Upgrade',
	   			PurchaseDate = now,
	   			RMR__c = 210.00, 
	   			Price = 500.00);
	   		assts.add(a);	 
		}
	    insert assts;
	    
	      //check results of accounts to be sure ClientSince date was updated to the PurchaseDate
		 list <Account> accs = [Select Id, Client_Since__c from Account Where CreatedById =: createdby];
		 for (Account a : accs){
		 	System.assertEquals(now, a.Client_Since__c);   
		 }  
	}
	
	public static void performUpdateOriginalPurchaseDate(string createdby){
		date now = date.today();
		// get a list of the original assets	
	 	list <Asset> insertedAsst = [Select Id from Asset where CreatedbyId =: createdby and Status = 'Attritioned-Upgrade'];
	 			
		//update original asset purchase date
		for (Asset ass : insertedAsst){
			ass.PurchaseDate = now;
		}		
		update insertedAsst;
			   
	     //check results of accounts to be sure ClientSince date was updated to the new PurchaseDate
		 list <Account> accs = [Select Id, Client_Since__c from Account Where CreatedById =: createdby];
		 for (Account a : accs){
		 	System.assertEquals(now, a.Client_Since__c);   
		 }  
	}
	
	public static void performDeleteAssets(string createdby){
		list<Account> accts = new list<Account>();	
		User u = [select Id from User where Id =: createdby];
		integer i = 0;
	    // create 100 accounts
	    for (i=0; i < 100; i++ ){
	    	Account acc = new Account(
	    		Name='Testing Account ' +i, 
	    		Industry='Nonprofit', 
	    		Type = 'Client',
	    		CreatedBy = u);
	    	accts.add(acc);
	    }	
	    insert accts;
	    
	    // insert one asset for each of the new accounts
	    list<Asset> assts = new list<Asset>();
		list<Account> insertedAccts = new list<Account>([Select id from Account where CreatedById =: createdby and Industry='Nonprofit']);
		Product2 prod = [select Id from Product2 where Name = 'Nonprofit Silver Level'];
	   	Product2 prod2 = [select Id from Product2 where Name = 'PrinterPresence Silver Level'];
	   
	    // create an asset for each account
		for (Account acct : accts ){
			Asset a = new Asset(
	   			Product2 = prod,
	   			Name = 'Nonprofit Silver Level',
	   			AccountID = acct.Id,
	   			Status = 'Purchased',
	   			PurchaseDate = date.newinstance(2012, 01, 01),
	   			RMR__c = 110.00, 
	   			Price = 3000.00);
	   		assts.add(a);	 
		}
	    insert assts;
	    
	    // delete assets for all accounts
	    list <Asset> AssetToDelete = [Select Id from Asset where CreatedbyId =: createdby and (Name = 'Nonprofit Silver Level' or name = 'PrinterPresence Silver Level')];
	    
		delete AssetToDelete;
		
		//check results of accounts to be sure ClientSince date was updated to empty for the newly created accounts
		 list <Account> accs = [Select Id, Client_Since__c from Account Where CreatedById =: createdby and Industry='Nonprofit'];
		 for (Account a : accs){
		 	System.assertEquals(Null, a.Client_Since__c);   
		 } 
		//check results of accounts to be sure ClientSince date was updated to the new PurchaseDate
		 list <Account> accs1 = [Select Id, Client_Since__c from Account Where CreatedById =: createdby and Industry='Printers'];
		 for (Account a1 : accs1){
		 	System.assertEquals(System.today(), a1.Client_Since__c);   
		 }  
	}
	
	public static void performCreateVersaDocAssets(string createdby){
	    // add PrinterPresence Platinum level Asset (Has VersaDoc)
	    date now = date.today(); 
	    list<Account> accts = new list<Account>([Select id from Account where CreatedById =: createdby]);	
	    Product2 product = [Select p.Name, p.Id From Product2 p where p.name = 'PrinterPresence Platinum Level'];
	    list<Asset> assets = new list<Asset>();
	   
	    for(Account a : accts){
	    	Asset ass = new Asset(
	    		Name=product.Name,
	    		Product2Id=product.Id,
	    		Status='Purchased',
	    		Price=7500.00,
	    		RMR__c=310.00,
	    		AccountId=a.Id,
	    		PurchaseDate=now);
	    	assets.add(ass);
	    }
	    insert assets;
	    
	    //check results of inserted accounts to be sure a VersaDoc Project Manager was assigned	
		list <Account> accs = [Select Id, AccountNumber from Account Where CreatedById =: createdby and Type = 'Client' and Name like 'Testing Account%'];
		
		Map<id, Account> acctTeams = new map<id, Account>([Select a.Id, (Select Id, AccountId From AccountTeamMembers WHERE TeamMemberRole = 'VersaDoc Project Manager' limit 1) From Account a Where a.Id in :accts]);
		for (Account a : acctTeams.values()){
			System.assertNotEquals(a.AccountTeamMembers, Null);
		}  
	}
}

 Thanks!

Hi Guys,

 

Is there any API which I can use to read data from salesforce and then move into another system?

 

I know I can give wsdl files and then they can use login api to login into salesforce.However,how will they read data and move it to some other system.

 

Thanks,

Hi!

I am calling an API of FluidSurvey. when i make a POST request ... it post the request on the fluidSurvey but i didnt get the JSON response. rather it returns nothing. any suggestion??

 

my controller code

public class fluidSurvey{

    public String tst{set;get;}
    public String result{get;set;}
    
    public PageReference chk() {
        getData();
        return null;
    }

    public void getData(){
        String apiKey = 'xxxxxx';
        String pwd = 'xxxxxx';
        String u = 'https://app.fluidsurveys.com/api/v2/surveys/survey_id/responses/';
        
        HttpRequest req = new HttpRequest();
        Http http = new Http();
        HTTPResponse res;
        try{
            req.setEndPoint(u);
            req.setTimeout(20000);
            req.setMethod('POST');
            Blob headerValue = Blob.valueOf(apikey + ':' + pwd);
            String authorizationHeader = 'Basic '+ EncodingUtil.base64Encode(headerValue);
            req.setHeader('Authorization', authorizationHeader);
            req.setHeader('Content-Type', 'application/json');
            req.setHeader('Content-Length','31999');
            
            res = http.send(req); 
            tst= res.toString();
                     
               
        
	       catch(Exception e){
               System.debug('Callout error: '+ e);
               System.debug(tst+'--------'+res);
           }     
        }
       
}

 and the Apex page code is

<apex:page controller="newFS">
<center>
      <apex:form >
          <apex:pageBlock title="New Fluid Surveys API">
              <apex:outputText value="{!tst}"></apex:outputText><br/>
               <apex:pageBlockButtons location="bottom">
                  <apex:commandButton value="Submit" action="{!chk}"/>
               </apex:pageBlockButtons>   
          </apex:pageBlock>
      </apex:form>
      </center>
</apex:page>

 and api documentation link is http://docs.fluidsurveys.com/api/surveys.html#getting-a-list-of-surveys..

  • April 18, 2013
  • Like
  • 0

Hi All,

 

I have tried invoking Apex (SOAP based) web service by sending out bound message , but it's throwing error :

" INVALID_SESSION_ID: Invalid Session ID found in SessionHeader: Illegal Session"

 

Regards

Sameer

I have common problem which could be clear for more experienced developers: At the Save moment I'd like to check is the field in new record (for example the good serial number - SN) is already exist in another object list. If Yes, I should pickup the existing record Id. Else (if not exist) -- to create a new record. 

Hi all, 

 

I have a situation in which I need to make a API call after insert operation and in that API method I need to pass the ID of inserted object. Can it be possible? If yes then how? Please provide a solution urgently.

 

Thanks-

Vishal Gupta

Hello,

 

Can someone help me with an idea in finding the average age of opportunities in each stage?

 

Thanks in advance

Hello,

 

Integrating salesforce with twitter through apex code am facing error like

 

"Failed to validate oauth signature and token"

 

 

Am passing twitter Oauth token, secretkey... in string format like

 

string Stringval='Oauth_callback="'+EncodingUtil.urlEncode('https://c.ap1.visual.force.com/apex/twitterForcepage';, 'UTF-8')+'",oauth_consumer_key="eIGzjmMGeclmpSzxmjnKhQ", oauth_nonce="3de317379683f90d4f80da8879472036", oauth_signature="fiyY68Llzy2yREjUeJw0o%2Fdqcns%3D", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1365504459", oauth_token="354671694-MrReLR18pmpDZulKaRVZR3CifKpI9ZFo1XUofyJn", oauth_version="1.0"';

 

string bVal=EncodingUtil.Base64Encode(blob.valueof(Stringval)); 
String authorizationHeader = 'Bearer :' + bval;
req.setHeader('Authorization',bVal);

 

 

How to integrate salesforce with twitter through apex? how to authenticate with twitter? or acess responce from twitter?

 

Can anyone suggest my issue where it is problem?




Thank you

Hi All,

 

Can someone please help me with detailed steps for Migrating from Siebel to SFDC...

As i have never worked on Siebel I don't have any idea about that CRM but since have a requirement for migration would like to know it in detail.Also if you can provide any helpful pdfs,doc or links will be of Great Help...

 

 

 

Please kindly Help and Guide...

Req: I have no.of users in my instance and no.of entity subscriptions in my instance. Have to identify each individual users no.of entity subscription based on that want to delete some entity subscriptions of that user.  Have to write code by avoiding governor limits can any one help me on this

 

Step 1: List of users (No.of user in instance eg: 30 to 40 users)

 

Step 2: List on Entity subscriptions (Have to identify which user created how many Entity subscriptions)

 

Step 3: If particular user E.S count > 490 want to delete first 25 E.S of that user.

 

I written code but its crossing governor limits. Can any one help me on this ASAP. Thanks in advance

  • April 13, 2013
  • Like
  • 0

Hi All,

        I having SAP WSDL file how to connect this wsdl file with Salesforce.

 

        After connecting this WSDL file with salesforce, using this I want only to view the data. kindly anyone tell how to resolve this.

Thanks,

Regards,

Udaya

Hi ,

 

  My scenario is , if i create a employee details record in in salesforce , It will be Display in SAP/PI. 

 

  Employee objects

 

  Fields - Name,Ename__c & Salary__c

 

  Steps:

1) generate Apex class from sap/pi WSDL

2) create a new apex class (future methods ) and set enerated class end point.

3) write a trigger , to call future methods apex class

   

Generated Apex class from SAP PI system

 

public class intrigoSoapSforceCom456 {
    public class HTTPS_Port {
        public String endpoint_x = 'http://ca-in02:520/XISOAPAdapter/MessageServlet?senderParty=&senderService=BC_SFDCTEST&receiverParty=&receiverService=&interface=SI_SFDC_OUT&interfaceNamespace=urn:intrigo.soap.sforce.com';
        public Map<String,String> inputHttpHeaders_x;
        public Map<String,String> outputHttpHeaders_x;
        public String clientCertName_x;
        public String clientCert_x;
        public String clientCertPasswd_x;
        public Integer timeout_x;
        private String[] ns_map_type_info = new String[]{'urn:intrigo.soap.sforce.com', 'intrigoSoapSforceCom456'};
        public intrigoSoapSforceCom456.Response_element[] SI_SFDC_OUT(intrigoSoapSforceCom456.Employee_element[] Employee) {
            intrigoSoapSforceCom456.SfdcTest_Request request_x = new intrigoSoapSforceCom456.SfdcTest_Request();
            intrigoSoapSforceCom456.SFDCResponse response_x;
            request_x.Employee = Employee;
            Map<String, intrigoSoapSforceCom456.SFDCResponse> response_map_x = new Map<String, intrigoSoapSforceCom456.SFDCResponse>();
            response_map_x.put('response_x', response_x);
            WebServiceCallout.invoke(
              this,
              request_x,
              response_map_x,
              new String[]{endpoint_x,
              'http://sap.com/xi/WebService/soap1.1',
              'urn:intrigo.soap.sforce.com',
              'MT_SFDC_Request',
              'urn:intrigo.soap.sforce.com',
              'MT_SFDC_Response',
              'intrigoSoapSforceCom456.SFDCResponse'}
            );
            response_x = response_map_x.get('response_x');
            return response_x.Response;
        }
    }
    public class Response_element {
        public String sapno;
        private String[] sapno_type_info = new String[]{'sapno','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] apex_schema_type_info = new String[]{'urn:intrigo.soap.sforce.com','false','false'};
        private String[] field_order_type_info = new String[]{'sapno'};
    }
    public class SFDCResponse {
        public intrigoSoapSforceCom456.Response_element[] Response;
        private String[] Response_type_info = new String[]{'Response','urn:intrigo.soap.sforce.com','Response_element','1','-1','false'};
        private String[] apex_schema_type_info = new String[]{'urn:intrigo.soap.sforce.com','false','false'};
        private String[] field_order_type_info = new String[]{'Response'};
    }
    public class Employee_element {
        public String EmployeeNo;
        public String Ename;
        public String Salary;
        private String[] EmployeeNo_type_info = new String[]{'EmployeeNo','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] Ename_type_info = new String[]{'Ename','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] Salary_type_info = new String[]{'Salary','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] apex_schema_type_info = new String[]{'urn:intrigo.soap.sforce.com','false','false'};
        private String[] field_order_type_info = new String[]{'EmployeeNo','Ename','Salary'};
    }
    public class SfdcTest_Request {
        public intrigoSoapSforceCom456.Employee_element[] Employee;
        private String[] Employee_type_info = new String[]{'Employee','urn:intrigo.soap.sforce.com','Employee_element','1','-1','false'};
        private String[] apex_schema_type_info = new String[]{'urn:intrigo.soap.sforce.com','false','false'};
        private String[] field_order_type_info = new String[]{'Employee'};
    }
}

 

 

Apex class :

 

global class WebServiceCallout123 {
 
    @future (callout=true)
    WebService static void sendNotification(String EmployeeNo ,String Ename, String Salary) {
     //Set your username and password here
        String username = 'nreddy';
        String password = 'sappi123';
 
        //Construct HTTP request and response
        HttpRequest req = new HttpRequest();
        HttpResponse res = new HttpResponse();
        Http http = new Http();
        
         //Construct Authorization and Content header
        Blob headerValue = Blob.valueOf(username+':'+password);
        String authorizationHeader = 'Basic ' + EncodingUtil.base64Encode(headerValue);
        req.setHeader('Authorization', authorizationHeader);
       req.setHeader('Content-Type','application/json');
        
         //Set Method and Endpoint and Body
        req.setMethod('POST');
        req.setEndpoint('http://ca-in02:520/XISOAPAdapter/MessageServlet?senderParty=&senderService=BC_SFDCTEST&receiverParty=&receiverService=&interface=SI_SFDC_OUT&interfaceNamespace=urn:intrigo.soap.sforce.com');
        
        req.setBody('{"EmployeeNo":"'+EmployeeNo+'","ename":"'+ename+'","Salary":"'+Salary+'"}');
        System.debug('EmployeeNo -->' + EmployeeNo); 
        try {
           //Send endpoint to JIRA
           res = http.send(req);
            
        } catch(System.CalloutException e) {
            System.debug(res.toString());
        }
    }

 

    
    public static testMethod void testMe() {
        WebServiceCallout123.sendNotification('aza','aza','aza');
    }
 
}

 

trigger:

 

trigger InsertEcc on Employee__c (after Insert) {

for(Employee__c s:Trigger.New)
{
   
     WebServiceCallout123.sendNotification(s.Name,s.Ename__c,s.Salary__c);
     System.debug('Emp data -->' + s);

 

}

}

 

The problem is it is not affected in sap /pi. Any body have a idea. what wrong i done? please help me

Hi all,

 

Sorry for the newbie questions, but I've been hunting around for some information on how to use JSON in Salesforce and found some good resources however I've still got some questions about how Salesforce can receive a JSON feed from another system and process the results accordingly.

 

The scenario is Salesforce will be receiving a regular feed of master data (finance accounts) from an ERP system. Specifically the quetions I have are:

 

  1. I've found examples that show how to serialise and deserialise JSON messages, however how is the JSON Apex Class exposed so the sending system can deliver it's message?
  2. How is the request authenticated?
  3. How do you map the JSON message onto a Custom Object? Is it simply a case of looping through the message once it's deserialised and insert / upserting into the object?

Any help or pointers gratefully received.

I am getting an error "SessionId invalid at this location" when I try to use Query method. I am tying to integrate PeopleSoft with SalesForce.com using SOAP API (consuming a Web service in PeopleSoft). I can successfully use the login method. Using the sessionId and serverURl, I get from login method, I am trying to use the query method. I gets above error. Can anyone help me?