• Dev_Arya
  • SMARTIE
  • 660 Points
  • Member since 2017
  • Senior CRM Consultant
  • ilum:e informatik AG


  • Chatter
    Feed
  • 20
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 9
    Questions
  • 172
    Replies
Hi, I'm new to triggers.
can someone help me with the below trigger.

NCT Object
  1. if field (Process 8a case) Court process field is NCT 
  2. Change case/query owner to NCT queue
  3. Open an NCT object
  4. Complete client full name in NCT object from case field

this is the where the  field is query owner(owner) located
query owner(owner) which is a lookup field.
should be Queue (1) and the next field should be NCT queque (2)  Below:
User-added image

This is what I did to change the Owner to NCT queue and got an ErrorUser-added image
 
I have 3 fields in a 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, 
I am using jitterbit to do upsert to salesforce object
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

 
Hello,
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;
    }
}

 
Learning Salesforce DX, have downloaded the DreamHouse project from gitHub site, made a new branch of my own.  Then, in the Unit of "Create and Test Our Scratch Org", at the beginning, it says "Enter cat config/project-scratch-def.json" to see some of the options available. When I did this in the command line, I got "cat not recognized as an internal or external command".  Online articles say that "cat" is a Unix code, can't be used in Windows system.  Now, my question is what should I use in Windows?

Thanks!
We have a working customization in place. No issues in Classic mode, but we receive this error in Lightning mode, when we add a case comment.
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)
One of our staff member accidentally deleted a contact that had revenue associated with it. I can still see the revenue via the campaign, but how do I re-associate the revenue with the new, replacement contact record? thanks.
  • February 14, 2018
  • Like
  • 0
Like a lot of people here, I am getting a "formula is too big to execute" error. A lot of the exemples I have seen had fairly complex formulas but mine is 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__c
Each 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.
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?
Hello,

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){}

}
Hi all,

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
I am trying to build a custom Send with DocuSign button that will perform three actions when clicked:
  1. Make sure all necessary Order Form fields are populated
  2. Populate the form with field merge data from Salesforce
  3. Identify which type of Subscription Order to send, and 
  4. Route the Order to the appropriate customer and internal Signing Group
I am getting the following Error: "A problem with the OnClick JavaScript for this button or link was encountered: missing ) after argument list" 

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. 
Hello,
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:
User-added image
#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.
Hi, I'm getting some errors later in this super badge, which is causing my component to not work properly, I believe this is related to poor code and I need some help cleaning it up. Here is what I have so far.

BoatSearch.cmp
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes" access="global" >
    <aura:handler name="formsubmit"
                  event="c:formsubmit"
                  action="{!c.onFormSubmit}"
                  phase="capture"/>
    
    <lightning:card title="Find a Boat" class="slds-m-top_10px" >
     <c:BoatSearchForm />
</lightning:card>    
<lightning:card title="Matching Boats" >
     <c:BoatSearchResults aura:id="BSRcmp"/>
</lightning:card>
</aura:component>
BoatSearchController.js
({
    onFormSubmit : function(component, event, helper){
        console.log("event received by BoatSearchController.js");
        var formData = event.getParam("formData");
        var boatTypeId = formData.boatTypeId;
        var BSRcmp = component.find("BSRcmp");
        var auraMethodResult = BSRcmp.search(boatTypeId);
        console.log("auraMethodResult: " + auraMethodResult);
    }

})
BoatTypeController.apex
public class BoatTypeController {
@AuraEnabled
    public static List<String> getpickval() {
        List<String> options = new List<String>();

        Schema.DescribeFieldResult fieldResult = BoatType__c.Name.getDescribe();

        List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();

        for (Schema.PicklistEntry f: ple) {
            options.add(f.getLabel());
        }       
        return options;
    }
}









 
I'm not clear why they're instructing us to package up the BoatTypeId as a property of an object called formData. Why not just pass the BoatTypeId directly?  Here's what it says:
 
Use a new event c:FormSubmit named formsubmit with an Object attribute named formData to pass the selected boatTypeId—as a property of formData—from BoatSearchForm to its parent component BoatSearch. Do this via a controller function called onFormSubmit() attached to the Search button.
In the 
BoatSearch component, handle FormSubmit with a controller action named onFormSubmit. Pass formData.boatTypeId from the controller to a public method on the BoatSearchResults component called search.
 
Why not just do this:
onFormSubmit : function(component, event, helper){
        var boatTypeId = component.get("v.selectedType");
        console.log("Search button pressed " + boatTypeId);
        var formSubmit = component.getEvent("formsubmit");
        formSubmit.setParams({"boatTypeId": boatTypeId});
        formSubmit.fire();
    },

 
HI All,
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
Hi All,

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,
I had 4000 points in my username: goutham2589@gmail.com. due to some issues, I couldn't login using that username. so, I created new username gautam@sindam.com . I want to migrate my points to new username account. how?

Thanks in advance! 
Practice Use Case:

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.  
Hi Reader,

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.
Hi All,
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
I need to add additional related list 'Associated Accounts' to Campaign and show the 'Number Of Associated Accounts' in Campaign Detail Page. So far it was pretty straight forward to achieve.
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
Hi All,

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
Hi All,

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.
 
hi all,

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.
 
Hi All,

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
Hi All, 

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
Hi, We have a requirement related to Manage Audience for our Partner community (This question here is a follow up of the same question I posted on success community, seeking developers approach). The page variation should be based on users profile and country, for example, if user's profile is 'abc' and user's account country IS NOT 'Germany', only then the page should be visible. I have done profile restriction, and under Profile selection, one could choose user's  account country picklist field but enter criteria does not show  'construct a formula' panel, one cannot formulate it unlike other places. Hence I put couple of combinations like :<>'Germany' ; <>"Germany" ; != "Germany" ; != 'Germany', (also tried with the abbreviation for the country i.e 'de'). But it is not working. 
Attached screenshot for the reference.
User-added image
 
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
Hi All,

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
Hi, I'm new to triggers.
can someone help me with the below trigger.

NCT Object
  1. if field (Process 8a case) Court process field is NCT 
  2. Change case/query owner to NCT queue
  3. Open an NCT object
  4. Complete client full name in NCT object from case field

this is the where the  field is query owner(owner) located
query owner(owner) which is a lookup field.
should be Queue (1) and the next field should be NCT queque (2)  Below:
User-added image

This is what I did to change the Owner to NCT queue and got an ErrorUser-added image
 
I have 3 fields in a 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, 
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
Hi guys, so, I have Salesforce Service Cloud, and on it, I made a settings to receives cases on social (Facebook & twitter) and on Email. on a daily basis, my organization receives 10K complaints  I once created a reply macro for email and it worked. the reason for this if for my team to reply email in a massive amount. this is what I have on email mass reply macro:

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?
Multiple users are getting an error message when trying to save an Opportunity. The message reads "The record you were editing was modified by XYZ user during your edit session". I'm familiar with this error and why it fires when two people are actively editing a record (Collision Detection), but the odd thing is that the other Users were NOT actively editing the same record at the same time. I'm assuming that something in the background is causing this error (Workflow, Process Builder, Flow, etc.), but does anyone know the best way to check this? Is there a way to determine if one of these elements threw the error? Or is there a way to see that user's log history for that time period?

User-added image
 

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!

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.
 

User-added image


 



 

Hello, I still getting comfortable with triggers and was wondering if anyone could help me with a trigger based on a customer object. I have a custom object for integrations and am looking for a trigger that updates the integration status based on the opportunity pipeline. 
Hi, I am planning to attend App Builder certification soon. can anybody help with sending dumps to my email? Email: mouni4jb@gmail.com or any type of info about cerification exam which would help me? please let me know... thanks
Hi, 
I cannot find the gear icon in Trailhead.  I am new and working on the suggestion box project.  The very first step asks me to click on the gear button, then click on setup.  I am working in Chrome and have the latest version of the browser. 

Thanks, 
John McCann 
Hello, 

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.
I need to make a REST callout. I have more than 400 records at time( after bulk insert (more than 400 records ) and  then  need to make callout for sending each record to external sytem)  .
Please guide whcih approach is better to follow
Create a batch and make callouts from the batch (scope is 1)
Or 
Create trigger and then excecute the queueable apex to make callout 
  • February 27, 2018
  • Like
  • 0
In the following piece of code:
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, columnB
The 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?