-
ChatterFeed
-
19Best Answers
-
1Likes Received
-
1Likes Given
-
12Questions
-
173Replies
trigger on a lookup field
can someone help me with the below trigger.
NCT Object
- if field – (Process 8a case) Court process field is NCT
- Change case/query owner to NCT queue
- Open an NCT object
- Complete client full name in NCT object from case field
query owner(owner) which is a lookup field.
should be Queue (1) and the next field should be NCT queque (2) Below:
This is what I did to change the Owner to NCT queue and got an Error
-
- Raymond Mortu
- March 07, 2018
- Like
- 0
- Continue reading or reply
Validation rule to enforce users to enter all values in a section even if one value is entered in that section
I have to write a validation rule when a value is entered in one field in a section enforce the user to key in values for all other fields in that section.
AND(
OR(
AND(
(x__c> 0),
OR(
ISBLANK(y__c),
ISBLANK(z__c)
)
),
AND((y__c > 0),
OR(
ISBLANK(x__c ),
ISBLANK(z__c)
)
),
AND((z__c > 0),
OR(
ISBLANK(x__c ),
ISBLANK(y__c )
)
)
),
(RecordType.Name = "abc")
)
Here is my VR.... Any help would be appreciated.. thanks,
-
- Aruna Dhavaleswarapu 4
- March 07, 2018
- Like
- 0
- Continue reading or reply
CSV file upload validation
List<String> necessaryColumns = new List<String> {'columnA', 'columnB', 'columnC', 'columnD', 'columnE', 'columnF','columnG'}; Set<String> columnsInFile = new Set<String>(necessaryColumns); System.debug('columnsInFile' + columnsInFile); // Get all column names from the CSV file List<String> columnNames = csvRecords.get(0); for(String columnName :columnNames) { System.debug('columnName: ' + columnName); if(!columnsInFile.contains(columnName)) { System.debug('clmnName: ' + columnName); ApexPages.Message myMessage = new ApexPages.Message(ApexPages.Severity.FATAL, 'The uploaded file is invalid'); ApexPages.addMessage(myMessage); return; } }The issue I have is that the names of the columns in the set are in strict order.
|DEBUG|columnsInFile{columnA, columnB, columnC, columnD, columnE, columnF, columnG}and if the order of the columns in the CSV file is changed for instance:
columnG, columnF, columnD, columnC, columnA, columnBThe algorithm is entering the if block and is showing the message, which is totally wrong.
What I'm trying to achieve is to show the message only if one of the columns in the CSV file is missing.
If there are 20 columns in the CSV file but for instance columnA is missing in the file only then the ApexPages.Message has to be displayed for the users.
Please advise how this can be achieved with apex?
-
- sfadm sfadm
- February 27, 2018
- Like
- 0
- Continue reading or reply
asd
When I try to upsert, i keep getting message
The operation "Upsert Investments" failed. Error Transformation failed but no error was reported. Fatal Error Transformation failed.
Please suggest solution.
Last upsert operation on same object took quiet a long time, after that it started giving me this error on that upsert object.
Please guide, need help urgently
Thanks for any replies or help in advance
-
- parag r 4
- February 25, 2018
- Like
- 0
- Continue reading or reply
Populating list from Set Id in Trigger
I thought I had a simple straight forward code......never the case for me! Basically what I'm looking to do is if the ContentNote is updated or created, then push that note to a field in the Lead. Since ContentNote uses ContentDocumentLink as a sort of junction the Trigger is based of the ContentDocumentLink. Also, a trigger is not possible from the ContentNote itself (at least I couldn't find it). My code fails on line 9 showing error in the log of "FATAL_ERROR System.QueryException: List has no rows for assignment to SObject". Even though the log also shows the SOQL pulls 1 record. Any advice on getting this to work properly?
Trigger:
trigger Note on ContentDocumentLink (after insert, after update){ Set<Id> cnote = new Set<Id>(); Set<Id> leed = new Set<Id>(); for(ContentDocumentLink cl : Trigger.new){ cnote.add(cl.ContentDocumentId); leed.add(cl.LinkedEntityId); } ContentNote cn = [SELECT Id,Content FROM ContentNote WHERE Id IN :cnote]; Lead ld = [SELECT Id,Last_Note__c FROM LEAD WHERE Id IN :leed LIMIT 1]; for(ContentDocumentLink clnk : Trigger.new){ ld.Last_Note__c = cn.Content.toString(); update ld; } }
-
- Ryan Greene
- February 22, 2018
- Like
- 0
- Continue reading or reply
cat not recognized as an internal or external command
Thanks!
-
- Su Wang 3
- February 19, 2018
- Like
- 1
- Continue reading or reply
"A workflow or approval field update caused an error when saving this record. Contact your administrator to resolve it"
Our customization is to add the comment to a new field located on the case object. This Text Area field has a 255 character limit. The way it works in classic mode, you add a very long comment to the case, there is a workflow which takes the contents of the last comment, and performs a field update workflow action. Since this text area field has a limit of 255 characters, Salesforce automatically truncates the text from the CommentsBody to fit in this field. When I switch to Lightning mode, the same action throws the following error
New Case Comment
Review the errors on this page.
- A workflow or approval field update caused an error when saving this record. Contact your administrator to resolve it. Last Case Comment Internal: data value too large:
- (max length=255)
-
- Scott Russo
- February 15, 2018
- Like
- 0
- Continue reading or reply
Contact record and revenue
-
- cbc
- February 14, 2018
- Like
- 0
- Continue reading or reply
My Formula is too big to execute - Pretty silly
I have added product fields to my contracts and I want to add-up the price fields.
Former formula was:
prix_1__c + prix_2__c + prix_3__c + prix_4__c + prix_5__c + transport__c + prix_6__c
I want to change it up to
prix_1__c + prix_2__c + prix_3__c + prix_4__c + prix_5__c + prix_6__c + prix_7__c + prix_8__c + prix_9__c + prix_10__c + prix_11__c + prix_12__cEach of the field I am refering too is a 3 character text field. There is no way that should bring me over 5000 characters.
In the previous version, 4 of the fields were text and the others were currency and it worked (not sure how that worked.) Now I have changed them all to text and no dice.
Thank you.
-
- Chantal Fournier
- February 13, 2018
- Like
- 0
- Continue reading or reply
Hii Everyone!! I have to deactivate an trigger which is currently running without deleting it. Anyone help me to solve this.
trigger UpdateStage on Account (after insert, after update) List<Id> accountId = new List<Id>(); for(Account acc : Trigger.new) { if(acc.All_Opportunities_Won__c==True) accountId.add(acc.Id); } List<Opportunity> oppsToUpdate = new List<Opportunity>(); for(Opportunity opp : [select id, StageName, Amount from Opportunity where AccountId in: accountId AND Amount != 0]) { opp.StageName='Closed-Won'; oppsToUpdate.add(opp); } update oppsToUpdate; }
This is my apex Trigger. how to deactivate this?
-
- iswarya sekar 7
- December 08, 2017
- Like
- 0
- Continue reading or reply
Though i have entered limitation - Too Many Query rows 50001
I have used limitation in query still i am facing the same problem, can anyone help me here please.
global class POCreationBatch implements Database.Batchable<sObject>
{
global Database.QueryLocator start(Database.BatchableContext DBC)
{
return Database.getQueryLocator([Select Id,Name,Purchase_Order_Type__c,ActiveContractAsset_Count__c from Account where Purchase_Order_Type__c='Required for Invoice' limit 5000]);
}
global void execute(Database.batchableContext bc,List<sObject> scope)
{
List<Account> accountList = (List<Account>)scope;
Set<Id> accountIdSet = new Set<Id>();
for(Account accountRecord : accountList)
{
accountIdSet.add(accountRecord.id);
}
ProductOrderUtils POU = new ProductOrderUtils();
POU.createPurchaseOrders(accountIdSet);
}
global void finish(Database.batchableContext BC){}
}
-
- learn_sfdc
- December 04, 2017
- Like
- 0
- Continue reading or reply
-
- swapna muthiyalu
- December 04, 2017
- Like
- 0
- Continue reading or reply
How can I get other fields' value of recordId attribute in Lightning component?
How can I get other fields' value of recordId attribute in Lightning component?
For instance, recordId of Opportunity, want to get AccountId of this opportunity
-
- Lek Lextech
- November 29, 2017
- Like
- 0
- Continue reading or reply
OnClick JavaScript error when building a Send with DocuSign button
- Make sure all necessary Order Form fields are populated
- Populate the form with field merge data from Salesforce
- Identify which type of Subscription Order to send, and
- Route the Order to the appropriate customer and internal Signing Group
Here is all of my code. I have never used JavaScript before so this may be completely wrong but I bought a JavaScript Udemy class over the weekend to try and accomplish this goal. Any assistance you could provide would be greatly appreciated. Thank you!
Code:
{!REQUIRESCRIPT("/soap/ajax/19.0/connection.js")}
//Verify that all fields are filled out
if(ISBLANK({!Opportunity.Subscription__c})||
ISBLANK({!Opportunity.Product__c})||
ISBLANK({!Opportunity.Payment_Terms__c})||
ISBLANK({!Opportunity.Project_City__c})||
ISBLANK({!Opportunity.Delivery__c})||
ISBLANK({!Opportunity.Payment_Terms__c})||
ISBLANK({!Opportunity.Primary_Contact__c})||
ISBLANK({!Opportunity.Accounting_Contact__c})||
ISBLANK({!Opportunity.Amount}))||
{
alert ("Please fill out all fields in the Order Form Information and Contract Detail sections.");
}
//Fill out and send Consultant Subscription template if the Subscription is Consultant
elseif({!Opportunity.Subscription__c}=="Consultant Subscription"||
{
CES='Please DocuSign: StreetLight Data Consultant Subscription'; //Email Subject
CEM='Attached is the StreetLight Data Subscription order for your signature. Thank you!'; //Email Message
LA='0'; //List Attachments from within Notes and Attachments - 0 or 1
DST='11647cd6-93eb-456a-94d1-9e0a4b7303b1'; //Default Standard Template ID
OCO='Send'; //On Click Options - Send or Tag
CRL='Email~(!Opportunity.Primary_Contact__c};LastName~{!Opportunity.Primary_Contact__c};RoutingOrder~1;Role~R1';
CCRM='Customer Signer~Signer 1';StreetLight Signer~Signer 2';
//********* Page Callout (Do not modify) *********//
window.location.href="/apex/dsfs__DocuSign_CreateEnvelope?DSEID=0&SourceID={!Opportunity.Id}&RC="+RC+"&RSL="+RSL+"&RSRO="+RSRO+"&RROS="+RROS+"&CCRM="+CCRM+"&CCTM="+CCTM+"&CRCL="+CRCL+"&CRL="+CRL+"&OCO="+OCO+"&DST="+DST+"&CCNM="+CCNM+"&LA="+LA+"&CEM="+CEM+"&CES="+CES+"&SRS="+SRS+"&STB="+STB+"&SSB="+SSB+"&SES="+SES+"&SEM="+SEM+"&SRS="+SRS+"&SCS="+SCS+"&RES="+RES;
//*******************************************//
}
//Verify that all fields are filled out
if(ISBLANK({!Opportunity.Subscription__c})||
ISBLANK({!Opportunity.Product__c})||
ISBLANK({!Opportunity.Payment_Terms__c})||
ISBLANK({!Opportunity.Project_City__c})||
ISBLANK({!Opportunity.Delivery__c})||
ISBLANK({!Opportunity.Payment_Terms__c})||
ISBLANK({!Opportunity.Primary_Contact__c})||
ISBLANK({!Opportunity.Accounting_Contact__c})||
ISBLANK({!Opportunity.Amount}))||
{
alert ("Please fill out all fields in the Order Form Information and Contract Detail sections.");
}
//Fill out and send Pay-per-use Subscription template if incorporated the Subscription is Pay-per-use
elseif({!Opportunity.Subscription__c}=="Pay-per-use Subscription"||
{
CES='Please DocuSign: StreetLight Data Pay-per-use Subscription'; //Email Subject
CEM='Attached is the StreetLight Data Subscription order for your signature. Thank you!; //Email Message
LA='0'; //List Attachments from within Notes and Attachments - 0 or 1
DST='07a29bf3-225e-494d-8c55-88fa5822e960'; //Default Standard Template ID
OCO='Send'; //On Click Options - Send or Tag
CRL='Email~{!Opportunity.Primary_Contact__c};LastName~{!Opportunity.Primary_Contact__c};RoutingOrder~1;Role~R1';
CCRM='Customer Signer~Signer 1';StreetLight Signer~Signer 2';
//********* Page Callout (Do not modify) *********//
window.location.href="/apex/dsfs__DocuSign_CreateEnvelope?DSEID=0&SourceID={!Opportunity.Id}&RC="+RC+"&RSL="+RSL+"&RSRO="+RSRO+"&RROS="+RROS+"&CCRM="+CCRM+"&CCTM="+CCTM+"&CRCL="+CRCL+"&CRL="+CRL+"&OCO="+OCO+"&DST="+DST+"&CCNM="+CCNM+"&LA="+LA+"&CEM="+CEM+"&CES="+CES+"&SRS="+SRS+"&STB="+STB+"&SSB="+SSB+"&SES="+SES+"&SEM="+SEM+"&SRS="+SRS+"&SCS="+SCS+"&RES="+RES;
//*******************************************//
}
Thank you!
Cheers,
Sarah
P.S. Apologies for posting this question here but DocuSign support doesn't provide JavaScript assistance and StackOverflow was not the kindest with my question.
-
- Sarah Boggio 3
- November 28, 2017
- Like
- 0
- Continue reading or reply
what does this line mean: Database.DeleteResult result = Database.delete(acct, false);
This is from a trailhead (Test Apex Trigger).
There are 3 parts of the test class (under the trigger) that I have numbered 1, 2, 3 which I do NOT understand:
trigger AccountDeletion on Account (before delete) { // Prevent the deletion of accounts if they have related opportunities. for (Account a : [SELECT Id FROM Account WHERE Id IN (SELECT AccountId FROM Opportunity) AND Id IN :Trigger.old]) { Trigger.oldMap.get(a.Id).addError( 'Cannot delete account with related opportunities.'); } }And here, below, is the test class with the 3 parts I do not understand:
#1: Could you possibly explain in detail line 16?
On the left of the =, it seems like "result" is an object of a Class "Database.DeleteResult"????? I do not understand how this is being written.
On the right of the =, it seems like "database.delete" is deleting the object Acc???? but what does the false mean?
#2: the .isSuccess() looks like a method but... what does it really do?
#3: What does the sentence in the red square mean?
Thank you very much.
-
- EdCode
- November 28, 2017
- Like
- 0
- Continue reading or reply
How do I know whether it is sandbox or production ?
I am using the streaming API via the node module nforce , however I would like to understand how can I know with the instance url and the access token whether it belongs to sandbox or production ?
Regards,
Hema
-
- Hemalatha Rajendran
- November 11, 2017
- Like
- 0
- Continue reading or reply
Class Error
Hope everybody doing well,
I have studied about enum datatype and trying to understand it by using the below code.
But it throw me an error while saving the apex class MyExample.
Please let me know how to resolve this?
Season:
public enum Season {
WINTER,SPRING,SUMMER,FALL
}
Month:
public enum Month {
JAN,FEB,MAR,APR,MAY,JUN,JUL,AUG,SEP,OCT,NOV,DEC
}
MyExample:
public class MyExample {
public List seasonMonths(Season s)
{
List listMonths = new List();
if(s==season.WINTER)
{
listMonths.add(Month.DEC);
listMonths.add(Month.JAN);
listMonths.add(Month.FEB);
}
else if(s==season.SPRING)
{
listMonths.add(Month.MAR);
listMonths.add(Month.APR);
listMonths.add(Month.MAY);
}
else if(s==season.SUMMER)
{
listMonths.add(Month.JUN);
listMonths.add(Month.JUL);
listMonths.add(Month.AUG);
}
else if(s==season.FALL)
{
listMonths.add(Month.SEP);
listMonths.add(Month.OCT);
listMonths.add(Month.NOV);
}
return listMonths;
}
}
Thanks,
-
- Saroja Murugan
- November 08, 2017
- Like
- 0
- Continue reading or reply
Migrate my Trailhead points from old username to new username
Thanks in advance!
-
- gautam sindam
- November 07, 2017
- Like
- 0
- Continue reading or reply
Hello Team, I Want Write Trigger Could you pls Help Me how to write this Use Case Pls i am begginer..
1.create a checkbox 'create contact' on Account.
2.create a trigger which handles events like account insert, update, delete.
3.Trigger will be responsible for creating contact with defined set of fields. It will be responsible to keep key information of contact updated from Account. Hence Account will still be treated as master for key information.
-
- Mayur Shinde
- November 07, 2017
- Like
- 0
- Continue reading or reply
Limit products visibility using pricebook
Hi,
Related to: Products & Pricebook
By default, Salesforce does not provide sharing visibility control on Products, but we can limit the product access using the Pricebook assignment and users will only have access to the products added to the accessible pricebook. I tried implementing the above scenario, buy my users can still see all the products via a global search and products tab. Any idea why this could happen or otherwise how can I achieve the above-stated scenario? Thanks.
-
- Dev_Arya
- September 20, 2020
- Like
- 0
- Continue reading or reply
How to remove read/write access on a record for a particular profile?
-
- Dev_Arya
- June 24, 2020
- Like
- 0
- Continue reading or reply
what is the use of 'Restrict picklist to values defined in the value set' checkbox?
-
- Dev_Arya
- June 08, 2020
- Like
- 0
- Continue reading or reply
Bulk Delete operation in trigger does not split data in chunks of 200
As far I know, while processing bulk operations in Trigger, the data is split in chunks of 200 per batch. I have around 40K accounts in org and I wanted to delete around 1000 of them. To understand limits, I wrote a simple after trigger with limits check in it.
trigger Account_After on Account ( after delete, after insert, after undelete, after update ) { if(Trigger.isDelete){ System.debug('Number of records executed in this batch: ' + Trigger.old.size()); System.debug('Returns the total number of SOQL queries that can be issued.: ' + Limits.getLimitQueries()); System.debug('Returns the number of DML statements (such as insert, update) that have been called.: ' + Limits.getDMLStatements()); System.debug('Returns the number of SOQL queries that have been issued.: ' + Limits.getQueries() ); } }I executed the code anonymous:
List<Account> A = [Select Id from Account LIMIT 1000]; Database.Delete(A, false);I expected, this trigger to run 5 times in batch of 200 each; however the output I received was one batch with 1000 records.
15:35:05:125 USER_DEBUG [95]|DEBUG|Number of records executed in this batch: 1000 15:35:05:126 USER_DEBUG [96]|DEBUG|Returns the total number of SOQL queries that can be issued.: 100 15:35:05:126 USER_DEBUG [97]|DEBUG|Returns the number of DML statements (such as insert, update) that have been called.: 1 15:35:05:126 USER_DEBUG [98]|DEBUG|Returns the number of SOQL queries that have been issued.: 3
Why the records got deleted in one batch, or my understanding of bulk trigger is wrong?
Thanks. Cheers.
-
- Dev_Arya
- March 07, 2018
- Like
- 0
- Continue reading or reply
Marketing User check in validation rule
I need to create a validation rule on User object checking if user is Marketing user or not. I cannot use profile based check bcz in our org Marketing User is not constrained by profile. I found that at the API level, we can use the 'UserPermissionsMarketingUser' API name in the SOQL query to check for Marketing User permission, but this is not accessible at the validation level.
Although the solution was achieved using a before trigger, but i am curious to know if there is any way to detect the marketing user at the validation level or in the formulae?
Cheers,
Dev
-
- Dev_Arya
- February 13, 2018
- Like
- 0
- Continue reading or reply
How to achieve behavior similar to Campaign Hierarchy for a Custom field(Associated Accounts)?
I also need to maintain the associated accounts count for complete Campaign Hierarchy. I started writing the code, however with my limited Apex skills, I could not achieve this without a SOQL (Select) stmt in the for loop, it was required to get the details of the parent Campaign.
Is there any other way of achieving it with some join SOQL queries, so I do not need to search for parent campaign in for loop?
trigger Campaign_Accounts_After on Campaign_Accounts__c (after insert, after delete, after undelete) { //1. Update Campaign Number of Accounts in Campaign and Parent Campaigns if(trigger.isInsert || trigger.isUpdate){ //List<Campaign> parentCampaignsUpdate = new List<Campaign>(); Set<Id> associatedCampaignIds = new Set<Id>(); for(Campaign_Accounts__c campaignAccounts : Trigger.new){ associatedCampaignIds.add(campaignAccounts.Campaign__c); } List<AggregateResult> campaignAccountsCount = [SELECT Campaign__c, COUNT(Account__c) FROM Campaign_Accounts__c WHERE Campaign__c IN : associatedCampaignIds GROUP BY Campaign__c]; List<Campaign> campaignsUpdate= new List<Campaign>(); for(AggregateResult ar : campaignAccountsCount){ Campaign c = new Campaign(); //System.debug(ar.get('expr0')); c.Accounts_in_Campaign__c = (Integer)ar.get('expr0'); //c.HierarchyNumberOfAccounts__c = c.Accounts_in_Campaign__c; //for this also I need to iterate all the child campaigns c.Id = (Id)ar.get('Campaign__c'); campaignsUpdate.add(c); } update campaignsUpdate; //Maintain the hierarchy, search for parents for (Campaign campaign : [SELECT Accounts_in_Campaign__c, HierarchyNumberOfAccounts__c, ParentId FROM Campaign WHERE Id IN :campaignsUpdate]) { Campaign childCampaign = new Campaign(); if(campaign.ParentId != null){ // In this foor loop: I need to write SOQL to get the Parent Campaign Details and check if Parent has further a parent Campaign or not. // I am lost here. } } }
Cheers,
Dev
-
- Dev_Arya
- January 19, 2018
- Like
- 0
- Continue reading or reply
scratch org from developer sandbox
We are trying to setup SalesforceDX in our company and I am stucked with a very basic understanding of the SalesforceDX architecture.
So Far we have Developer Sandbox for every developer. But from now on, we wish to have one developer sandbox and developers must create scratch orgs from this Developer Sandbox and when developer is done testing on QA Sandbox, then the changes are pushed to the production org.
In my understanding, to create a sratch org, user needs to login with Devhub org which is the production org. Every developer then needs to login with production login first to create the scratch org and then push the changes to VCS? Is my understanding correct here? If Devhub is enabled, why cannot we create scratch org from the developer sandbox? Could somebody explain the architecture? I tried to understand from different blogs but didnt get any substantial answer.
Thanks. Dev
-
- Dev_Arya
- January 08, 2018
- Like
- 1
- Continue reading or reply
Test Class : SeelAllData=false still select returns all the records
I have a batch class which retrieves user records and updates the users email. In my test class, I created 10 users and called the batch class. All good till here, but when I requery the user records to assert, it returns all the records from the org. This is strange to me. Could some explain me this behaviour.
Batch class
/** * Created by darya on 1/2/2018. */ global class UpdateQAEmailsBatch implements Database.Batchable<sObject> { global Database.QueryLocator start(Database.BatchableContext BC) { List<Id> profileIds = new List<Id>(); List<String> profileNameStrings = new List<String>{'System Administrator','Profile B','Profile C'}; for (Profile p : [SELECT Id FROM Profile WHERE Name in: profileNameStrings]) { profileIds.add(p.Id); } String[] emailFilters = new String[] { '%@company.com' }; String query = 'SELECT Id, Name, Email, ProfileId FROM User WHERE Email like :emailFilters AND ProfileId NOT IN :profileIds'; return Database.getQueryLocator(query); } global void execute(Database.BatchableContext BC, List<User> scope) { for (User usr : scope) { String email = usr.Email; email = email.replace('@', '=') + '@example.com'; usr.Email = email; } update scope; } global void finish(Database.BatchableContext BC) { //TODO: Send Email } }
Test class
/** * Created by darya on 1/3/2018. */ @isTest public with sharing class UpdateQAEmailsBatchTest { @TestSetup static void setup() { List<User> users = new List<User>(); List<Id> profileIds = new List<Id>(); List<String> profileNameStrings = new List<String>{'Profile C','Profile D','Profile E','Profile F','Profile G','Profile H'}; for (Profile p : [SELECT Id FROM Profile WHERE Name in: profileNameStrings]) { profileIds.add(p.Id); } for (Integer i = 0; i < 10; i++) { User user = new User(alias = 'testQA' + i, email = 'testUserQAUpdate' + i + '@company.com', LastName = 'testUserQAUpdate' + i, Username = 'testUserQAUpdate' + i + '@company.com', emailencodingkey = 'UTF-8', languagelocalekey = 'en_US', localesidkey = 'en_US', profileid = profileIds[(math.random() * (profileIds.size())).intValue()], country = 'United States', IsActive = true, CompanyName = 'Getinge France', Getinge_Company__c = 'Getinge', timezonesidkey = 'America/Los_Angeles'); users.add(user); } insert users; } static testmethod void executeBatch() { UpdateQAEmailsBatch batch = new UpdateQAEmailsBatch(); Test.startTest(); Database.executeBatch(batch); Test.stopTest(); List<User> users = [SELECT Id,Email FROM User]; System.debug('Here its returns all the records from the Org. It should only return the above created 10 records'); System.debug('users retrieved count: '+ users.size()); for (User user : users) { System.debug('Id: ' + user.Id + ' Email: ' + user.Email); Integer index = ((String) user.Email).indexOf('@'); System.assertEquals(((String) user.Email).substring(index, index + 12), '@example.com'); } } }Thanks in advance.
-
- Dev_Arya
- January 03, 2018
- Like
- 0
- Continue reading or reply
why this query with And clause in Where fails?
the soql in the following code is failing. Could somebody explain this to me.
Map<Id, String> profileIds = new Map<Id, String>(); profileIds.put('00eee000000xxxx','System Administrator'); profileIds.put('00eee00000yyyyy','YYY Profile'); profileIds.put('00eee00000zzzzz','ZZZ Profile'); List<User> users = [SELECT Id, Name, Email, ProfileId FROM User WHERE NOT(Email like '%@example.com') AND ProfileId NOT IN :profileIds.keySet()]; System.debug(users.size()); for (User usr: users) { System.debug(usr.id+' '+usr.Email); }Where i remove one of the clause from the where statement, it works.
Thanks.
-
- Dev_Arya
- January 02, 2018
- Like
- 0
- Continue reading or reply
Dotnet integration using Connected App ends in login over insecure channel
I am trying to develop a sample dotnet integration app using the instructions specified in this tutorial:
https://www.youtube.com/watch?v=c0R7_4ctgHU
I have setup the connected app and in the connected app, the callback url is
"https://loginsalesforce.com/services/oauth2/callback" . My Org has a custom domain, does that make any difference in setting up the connected app? I also checked the TLS settings, tried activating and deactivating the TLS 1.2, but nothing works. My login function is as following:
private async void btn_login_Click(object sender, EventArgs e) { String sfdcUserName = txt_username.Text; String sfdcPassword = txt_password.Text; String sfdcSecurityToken = txt_securitytoken.Text; String SfdcloginPassword = sfdcPassword + sfdcSecurityToken; txt_output.Text = ""; var dictionaryForUrl = new Dictionary<String, String> { {"grant_type","password" }, {"client_id", sfdcConsumerkey}, {"client_secret", sfdcConsumerSecret}, {"username", sfdcUserName}, {"password", SfdcloginPassword} }; HttpClient authhc = new HttpClient(); HttpContent httpContent = new FormUrlEncodedContent(dictionaryForUrl); HttpResponseMessage httpresponse = await authhc.PostAsync("https://login.salesforce.com/services/oauth2/token", httpContent); String message = await httpresponse.Content.ReadAsStringAsync(); //Console.WriteLine(message); JObject jsonObj = JObject.Parse(message); authToken = (String)jsonObj["access_token"]; ServiceURL = (String)jsonObj["instance_url"]; String ErrorType = ""; String ErrorMsg = ""; ErrorType = (String)jsonObj["error"]; ErrorMsg = (String)jsonObj["error_description"]; // Console.WriteLine("AuthURL: " + authToken); //Console.WriteLine("ServiceURL: " + ServiceURL); if ((authToken != null && authToken != "") && ErrorMsg == null) { txt_output.AppendText("Login Successfull!!\n"); txt_output.AppendText("Instance url: " + ServiceURL); } else if (authToken == null && (ErrorMsg != "" && ErrorMsg != null)) { txt_output.AppendText("Login unsuccessfull!!\n"); txt_output.AppendText("Error Type: " + ErrorType + "\n"); txt_output.AppendText("Error: " + ErrorMsg); } }
For using this REST service to connect the salesforce, do I need additional code?
Thanks.
Best regards,
Dev
-
- Dev_Arya
- December 28, 2017
- Like
- 0
- Continue reading or reply
Compare the String field against other Datatype fields
Here is the scenario,
I have a custom field: 'strField' or Datatype String. I also have Case c, which has fields of type Date, Integer, String, Picklist, currency, etc.
I need to compare strField with Case c field. I cannot convert the Case c fields to String type because for numbers or Date or etc. , it will produce incorrect results.
For example
// this is wrong if(strField == String.vakueOf(c.CloseDate)){ // Do something } // this is also wrong if(strField == String.valueOf(c.someIntegerField)){ // Do something }Therefore, I need to cast the strField based on the Case c Field Datatype. I have the Case c field datatype but I do not know how to convert strField to that respective Datatype.
... String datatype = t.Textbaustein__r.Feld3__r.DataType; // this returns datatype in string format .... //I want to achieve this. The below code is wrong, it is just for reference: if((datatype)strField == c.get(t.Textbaustein__r.Feld3__r.QualifiedAPIName)){ // Do something }
Any help will be highly appreciated. (If anyone wants to know the complete use case, feel free to ask.)
Thanks.
Cheers,Dev
-
- Dev_Arya
- December 20, 2017
- Like
- 0
- Continue reading or reply
How to implement Community > Manage Audience based on field criteria (UI does not have NOT equal to operator) using APIs?
Attached screenshot for the reference.
From the success community I got the answe saying not possible from UI:
"The only operator that is being supported for user field is EQUALS, we do not currently support Not EQUAL or any other operators that you may see in other places. It is something we are planning to do in the future." - Ismail Kacini
So now I am looking for developer side answers in case anyone has achieved this.
Any suggestion will be highly appreciated. Thanks.
Cheers,Dev
-
- Dev_Arya
- November 16, 2017
- Like
- 0
- Continue reading or reply
scratch org from developer sandbox
We are trying to setup SalesforceDX in our company and I am stucked with a very basic understanding of the SalesforceDX architecture.
So Far we have Developer Sandbox for every developer. But from now on, we wish to have one developer sandbox and developers must create scratch orgs from this Developer Sandbox and when developer is done testing on QA Sandbox, then the changes are pushed to the production org.
In my understanding, to create a sratch org, user needs to login with Devhub org which is the production org. Every developer then needs to login with production login first to create the scratch org and then push the changes to VCS? Is my understanding correct here? If Devhub is enabled, why cannot we create scratch org from the developer sandbox? Could somebody explain the architecture? I tried to understand from different blogs but didnt get any substantial answer.
Thanks. Dev
-
- Dev_Arya
- January 08, 2018
- Like
- 1
- Continue reading or reply
Limit products visibility using pricebook
Hi,
Related to: Products & Pricebook
By default, Salesforce does not provide sharing visibility control on Products, but we can limit the product access using the Pricebook assignment and users will only have access to the products added to the accessible pricebook. I tried implementing the above scenario, buy my users can still see all the products via a global search and products tab. Any idea why this could happen or otherwise how can I achieve the above-stated scenario? Thanks.
- Dev_Arya
- September 20, 2020
- Like
- 0
- Continue reading or reply
what is the use of 'Restrict picklist to values defined in the value set' checkbox?
- Dev_Arya
- June 08, 2020
- Like
- 0
- Continue reading or reply
is clientID different from access token in case SOAP apis?
- Ali Khalil 8
- June 08, 2020
- Like
- 0
- Continue reading or reply
System.CalloutException: You have uncommitted work pending. Please commit or rollback before calling out. Test Method
I've been trying to do a test Method for a callOut class that invokes a Callout in a future Method, but this is returning System.CalloutException: You have uncommitted work pending. Please commit or rollback before calling out only in the test Execution, When running in the normal flow, it responses with no problem.
I've understood that this error is produced when doing a DML statement before a CallOut. However there's no operation besides the createData in the TestSetUp.
I've read some posts and the most likely was this one: https://developer.salesforce.com/forums?id=906F0000000927CIAQ .But the proposed solution of Test.StartTest(); Test.SetMock(); ... Test.EndTest() is already developed.
This is the code returning the error
@isTest global class RPP_SyncOportunidad_ws_tst { @testSetup static void createData() { Account acc = new Account(); acc = new Account(); acc.Name='AVX_cuentaPrueba '; acc.RPP_NombreComercial__c='NombreComercial '; insert acc; Contract contrato = RPP_DataGenerator_cls.crearContrato(true, acc.Id); Opportunity objOpp = RPP_DataGenerator_cls.crearOpportunity(false,acc.Id); objOpp.RPP_Acuerdo__c= contrato.Id; insert objOpp; } public static testMethod void successTest() { List<Opportunity> lstOpps = [SELECT Id FROM Opportunity]; Test.startTest(); Test.setMock(HttpCalloutMock.class, new MockSuccessResponse()); RPP_SyncOportunidad_ws mci = new RPP_SyncOportunidad_ws(lstOpps); Id jobId = System.enqueueJob(mci); Test.stopTest(); System.assertNotEquals(mci, null, 'Test error: Cannot create invocacion ws'); } global class MockSuccessResponse implements HttpCalloutMock { global HTTPResponse respond(HTTPRequest req) { HttpResponse res = new HttpResponse(); res.setHeader('Content-Type', 'application/json'); String strJSON ='[\n' + '{\n' + ' "CodigoError": null, \n' + ' "EntidadComercialId": "32201", \n' + ' "Estado": "S", \n' + ' "Mensaje": "Cliente registrado con éxito", \n' + ' "SalesForceGuid": "D58B1521-BAC2-4279" \n' + '}\n' + ']'; res.setBody(strJSON); res.setStatus('OK'); res.setStatusCode(200); return res; } } }It also happens that I have developed other CallOut classes with their own TestClasses and they work just fine.
Has anyone being in this issue?
- MaxSilveraN
- November 28, 2018
- Like
- 0
- Continue reading or reply
State/country picklist different on leads vs. contacts?
I am having an interesting issue. Our Salesforce instance is integrated with our company website. We are a subscription-model company selling content, so we sync contacts up to our website to determine which contacts have web accounts and also what these contacts have access to.
I am seeing a weird thing where I am getting errors for leads regarding the state in the state/country codes for leads only. So contacts are syncing all right, but leads seem to be erroring out.
But, I thought the state/country picklist was universal for the instance so that does not make much sense to me. Am I wrong in that assumption?
Any thoughts would be greatly appreciated.
Thanks,
Tasia
- Tasia Demuth 4
- October 03, 2018
- Like
- 0
- Continue reading or reply
Account Edting
- Saif
- October 03, 2018
- Like
- 0
- Continue reading or reply
Looking to have messages appended into a long text area field.
- Kevin Clemons
- October 03, 2018
- Like
- 0
- Continue reading or reply
Is there a maximum object to be stored in one document folder ?
we have (like other people I think) an issue with the storage of EmailMessage.
Therefore, we develop an apex class that will store each EmailMessage (and attachments) within a single document and retrieve if we need to restore the EmailMessage
As we have around 3 millions email, we will create around 3millions documents and I was wondering if there was a limit or recommandation regarding the number of object within a single folder.
This folder will never be directly access , we will only work with the id of the related document.
Thanks for your help
- challier fabrice
- October 03, 2018
- Like
- 0
- Continue reading or reply
trigger on a lookup field
can someone help me with the below trigger.
NCT Object
- if field – (Process 8a case) Court process field is NCT
- Change case/query owner to NCT queue
- Open an NCT object
- Complete client full name in NCT object from case field
query owner(owner) which is a lookup field.
should be Queue (1) and the next field should be NCT queque (2) Below:
This is what I did to change the Owner to NCT queue and got an Error
- Raymond Mortu
- March 07, 2018
- Like
- 0
- Continue reading or reply
Validation rule to enforce users to enter all values in a section even if one value is entered in that section
I have to write a validation rule when a value is entered in one field in a section enforce the user to key in values for all other fields in that section.
AND(
OR(
AND(
(x__c> 0),
OR(
ISBLANK(y__c),
ISBLANK(z__c)
)
),
AND((y__c > 0),
OR(
ISBLANK(x__c ),
ISBLANK(z__c)
)
),
AND((z__c > 0),
OR(
ISBLANK(x__c ),
ISBLANK(y__c )
)
)
),
(RecordType.Name = "abc")
)
Here is my VR.... Any help would be appreciated.. thanks,
- Aruna Dhavaleswarapu 4
- March 07, 2018
- Like
- 0
- Continue reading or reply
Business Hours Apex Trigger Help
trigger AfterHoursTrigger on Service_Call__c (after insert) { //Get the default business hours BusinessHours bh = [Select Id From BusinessHours Where isDefault = true]; Datetime CreatedTime = System.Today(); //Find whether CreatedDate is whithin those business hours for (Service_Call__C Calls : Trigger.new){ Boolean isWithin = BusinessHours.isWithin(bh.id, CreatedTime); if (isWithin = FALSE) Calls.After_Hours__c = True; } }
So this is my very first attempt to write a trigger in Salesforce so be patient with me. Basically I want something that will check a checkbox called "After Hours" if the created date of the record doesn't fall within the business hours set up in Salesforce. It's not working, and I have no idea why. Any help is appreciated. Thanks
- Adriana Reyes 26
- March 06, 2018
- Like
- 0
- Continue reading or reply
Service Cloud Macros - Create and Run Macros on Social Case - Can't complete
1. Select Active Case Tab
2. Select Close Case Action
3. Set Status: Process
4. Submit Action
5. Select Email Action
6. Set From Address: cs@company.com
7. Apply Email Template: [template name]
8. Submit Action
==============
Then, I tried to do similar thing on the social case, and it didn't work. This is what I have on social case macro:
1. Select Active Case Tab
2. Select Social Action
3. Set Message Type: Reply
4. Insert into Message: [quick text]
5. Submit Action
6. Select Create Activity Action
7. Set Group: [issue code group]
8. Set Issue Code: [issue code number]
9. Submit Action
10. Select Close Case Action
11. Set Status: Process
12. Submit Action
It is has different accordance, since it has different business process, but I'm sure every step is correct, yet, it still didn't work. Is macro only work for email? Is there any social case macro best practice example?
- Sultan Isnainsyah
- February 28, 2018
- Like
- 0
- Continue reading or reply
Create a PDF from record and records on related object
Hi guys,
I am trying to create a PDF file just like Quotes work. However im doing this from a Custom Object.
I found this link that answers it in some way :
https://developer.salesforce.com/forums/?id=9060G000000I7qhQAC
However im looking to create a pdf with some info from the record that is being created and the Line Items on the quote will come from data on records which this main record is related to.
Better explaining, i have Object A which will have the button to create the PDF, some of the main data will be pulled from the record on Object A, the line items(which may be just one or many, based on a criteria that i also want to specify) will pull from Object B, which has a lookup field to Object A on every record on the org.
So the PDF will generate with info from OBject A and every Object B that has object A related and meeting the criteria.
Lastly i want a second button that will create the PDF but will attach the PDF to an email with a preselected templated(email template created on salesforce) and automatically send it to the email on a contact lookup field on Object A.
Please advise the best way to create this procedures.
I really appreciate your help!
- Hermes Gomez
- February 28, 2018
- Like
- 0
- Continue reading or reply
Recurly Subscription changes: Process Builder: Too many SOQL queries: 201 - But record is updated
I have used Process Builder quite a bit in the past, however, this problem has stumped me.
I have a process that when a subscription record is changed, depending on which fields changed will push values from the subscription to the account record.
The subscription records are controlled and updated by Recurly ( our billing system). They have a batch job that runs every 5 minutes and pushes changes to SFDC. When a subscription changes, I use Process Builder to update the Account with the changed information.
I keep getting the following: Error Occurred: recurly_v2:Too many SOQL queries: 201
In fact, the email I get will reference about 45 records.
What is odd is following:
I received the email with the failure at 2:49 pm on 2/27/2016
The email failure reports record: ACCOUNT: 0010a00001MWEBt
That account record was last modified at 2/27/2018 4:29 AM
The subscription record that could have triggered this was last modified at 2/27/2018 4:43 AM
When I looked at the users record in Recurly there were no changes to that record at all?
When I try to dig through the Debug Logs I can not find any references to this WF at all?
Any help would be greatly appreciated.
- Wendy Schott 1
- February 28, 2018
- Like
- 0
- Continue reading or reply
Why are Dashboards Refreshing to Code?
I am wondering is anyone else has had this problem. When we are refreshing the dashboards, the dashboard just turns to code. It isn't anymore complicated than that. Literally, it is just html tags and styling. Does anyone know why this might be?
Thanks.
- Frances Allen
- February 27, 2018
- Like
- 2
- Continue reading or reply
CSV file upload validation
List<String> necessaryColumns = new List<String> {'columnA', 'columnB', 'columnC', 'columnD', 'columnE', 'columnF','columnG'}; Set<String> columnsInFile = new Set<String>(necessaryColumns); System.debug('columnsInFile' + columnsInFile); // Get all column names from the CSV file List<String> columnNames = csvRecords.get(0); for(String columnName :columnNames) { System.debug('columnName: ' + columnName); if(!columnsInFile.contains(columnName)) { System.debug('clmnName: ' + columnName); ApexPages.Message myMessage = new ApexPages.Message(ApexPages.Severity.FATAL, 'The uploaded file is invalid'); ApexPages.addMessage(myMessage); return; } }The issue I have is that the names of the columns in the set are in strict order.
|DEBUG|columnsInFile{columnA, columnB, columnC, columnD, columnE, columnF, columnG}and if the order of the columns in the CSV file is changed for instance:
columnG, columnF, columnD, columnC, columnA, columnBThe algorithm is entering the if block and is showing the message, which is totally wrong.
What I'm trying to achieve is to show the message only if one of the columns in the CSV file is missing.
If there are 20 columns in the CSV file but for instance columnA is missing in the file only then the ApexPages.Message has to be displayed for the users.
Please advise how this can be achieved with apex?
- sfadm sfadm
- February 27, 2018
- Like
- 0
- Continue reading or reply
Free text picklist
Thanks1!
- Vipin K 10
- March 02, 2017
- Like
- 0
- Continue reading or reply
Google single sign on prompt to select google account
My goal is to enable single sign-on with google into a community page. I have successfully connected a google auth provided to the community and the integration generally works, but i am noticing a bug.
Steps to reproduce:
1. navigate to community portal
2. press login with google button
3. sign in with google account without access to the page (my community does not enable new users to sign up)
4. visitor is provided an error message saying they cannot sign in.
5. visitor has another google account that _does_ have access to the portal so, navigates back to the portal login page.
6. visitor is directly logged into the original google account with no opportunity to change accounts.
Optimal behavior:
1. navigate to community portal
2. press sign in with google button
3. sign in with incorrect account
4. navigate back to portal login page
5. press sign in with google button
6. prompt to select a google account/oppotunity to login with another email/password
The 'prompt' option of google's javascript library has a way to configure this functionality. Is it possible to make this same configuration within the auth provider?
Thanks!
- Chase Starr
- October 03, 2018
- Like
- 1
- Continue reading or reply