• Ashish Dev
  • SMARTIE
  • 769 Points
  • Member since 2015

  • Chatter
    Feed
  • 22
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 233
    Replies
I'm trying to put together a SOQL query that would pull up the following information:

Part I:

SELECT Name, StageName, CloseDate, Amount, OwnerId,
FROM Opportunity WHERE StageName = 'Closed Won'
AND CloseDate = THIS_MONTH 

The part above works, but the problem is that I'm only getting the opportunity owner ID, not the name and I also need to limit output to the records where the owners have a specific role ID. 

The two pieces below are the pieces I need to add to the query and it seems that both of them are located on the User object. How do I write the relationship query that incorporates all three? 

Part II: 

FROM User WHERE UserRoleId = '00E0B000000zEGn'

Part III:

SELECT Username
We recently installed a new event registration application called Fonteva. We are having a problem with reporting on complete GL Account codes. The GL Account codes are truncated in reporting and they can't seem to come up with an answer for us to alleviate this issue. So I was thinking there might be some other way of doing this through potentially using Process Builder. My idea is this.

The Description field in the Transaction object has part of the GL Account Code, lets say '42300 Workshop Income' but the complete GL Account Code should be and look like this 4233-3-35 Workshop Income. Is there a way for me to create a field that when the incomplete code '42300 Workshop Income' posts it triggers a complete code of '4233-3-35 Workshop Income' in a custom field? I was thinking maybe this could be accomplished in Process Builder. Any help would be very much appreciated
Thanks in advance.
Hello,
I have a Visualforce page that performs the following:
  • saves record
  • shows success message 
  • closes VF page
  • refreshes salesforce page
Here is a snippet of the button.
<apex:commandButton action="{!save}" value="Save" onclick="setTimeout(Closewindow, 5000)" id="saveButton" reRender="Panel" />        
            &nbsp;&nbsp;&nbsp;&nbsp;
            <apex:commandButton value="Cancel" onclick="window.close();" immediate="true"/>
            </div>
            <apex:outputPanel id="Panel" style="font-size:16px;color:red">
                <apex:messages />
            </apex:outputPanel>

The issue is that I have required fields and a message alert the user that the field is required but  the issue is that the 
onclick="setTimeout(Closewindow, 5000)"
still runs. So the VF pages closes without saving the record.
Can the values be checked prior allowing the user select the 'Save' button?

M




 
I am getting the below error when trying to create a validation rule on a close date field on opportunity.
The rule must fire only for a specific Profile and only when this field is left blank.

User-added image
Appreciate your input.
  • May 31, 2018
  • Like
  • 0
Hello,

What are ways that a flow can be triggerd.

I know that processbuilder can trigger a Flow but are there any other ways to do that ?

thanks for suggestion !
 query = 'Select ' + CorrespondingFields + ' from ' + AllObjectsList;

Here,  object and fields of that object both are dynamic.
pls help how to display records in table on visualforce page.
Hello,

I have a use case like below.

When the Quote is approved, then all the people in certain profile for example XYZ should receive an email for Quote approval.

How is it possible to achieve it ?

thanks fo suggestion !
HI All,
We have a third party application which uses Visualforce page as REST API endpoint.
I checked the code and configuration and found there is NO connected app created in salesforce.

I was told that the third party application uses oauth2 to authenticate in Salesforce and sends http request to visual force page url, then reads the content of the visualforce page.
In the loggin history, I can see the login type is "other apex API".
On visualforce page, it is very simple
<apex:page contentType="text/plain; charset=UTF-8" controller="MobileIntegrationController" sidebar="false" showHeader="false" showChat="false" action="{!init}">
    {!responseString}
</apex:page>

It uses controller to generate the responseString and put as the content of the VF page.

Can someone please help me on this?

Thanks,
David
Hi Everyone?

I have trigger scenario i create contact automatically account will be created but i want update the contact details it is not update account record?

i write a code pls check this code? (insert work fine but update is not working ple help me as well as give me code also delete)


trigger acct on Contact (after insert,after update) {
    list<account>acct=new List<account>();
    Map<string,account> accountmap=new Map<string,account>();
    if(trigger.isafter){
        if(trigger.isinsert){
            for(contact con:trigger.new){
                account acc=new account();
                acc.Name=con.LastName;
                acc.id=con.AccountId;
                acc.Phone=con.Phone;
                acct.add(acc);
            } 
            insert acct;
        }
        if(trigger.isafter && trigger.isupdate){
            for(account acc:[select id from account WHERE id IN:trigger.newMap.keySet()]){
                accountmap.put(acc.Id, acc);               
            }
            for(contact con:trigger.new){
                account acc=new account();
                if(accountmap.containsKey(acc.Id))
                   acc.Id=accountmap.get(acc.Id).id;
                   acc.Phone=con.Phone;
                   acc.Name=con.LastName;
                    acc.Id=con.AccountId;
            }
        }
        if(acct.size()>0)
        update acct;
  }  
}



 
I need a programming code for a custom button to help me transfer a specific file from Salesforce onto another website like dropbox for example.

Is it even possible?
If it is possible can show me a workable code?

If not are there any way around it?
Seems simple but I want to embed a custom public calendar in a Visuaforce page.  I try using iFrames and they either show nothing or redirect.

These redirect the page entirely:
<iframe src="https://xxx.my.salesforce.com/00U/c?cType=1&cal_lkid=02341000000g22f&isdtp=vw"></iframe>
<iframe src="https://xxx.my.salesforce.com/00U/c?cType=1&cal_lkid=02341000000g22f&isdtp=p1"></iframe>

Without ISDP nothing displays in the frame
<iframe src="https://xxx.my.salesforce.com/00U/c?cType=1&cal_lkid=02341000000g22f"></iframe>

I have used both HTML iFrame as well as the Apex version.

Redirection is not an option because I want to put some buttons above the calendar and as such need it to sit within the page.
How do i block access to a particular field for multiple users having different profiles?
When i am trying to display error message when user try to insert/update a phone field with duplicate values code is fine but , when i try to update a phone field with null value its giving error as this phone already exists...what can i do for solving this error...

Code: trigger duplicatePhoneOnCandidate on Candidate__c (before insert ,before update) 
{
 
   Map<String, Candidate__c> candidateMap = new Map<String, Candidate__c>();

   Set<Id> setId = new Set<ID>();
    
for(Candidate__c candidates: System.Trigger.new)
{
        
setId.add(candidates.Id);
        
        
if( (candidates.Phone__c != null && System.Trigger.isInsert ) || 
    ( System.Trigger.isUpdate  && candidates.Phone__c != System.Trigger.oldMap.get(candidates.Id).Phone__c ) )
        
{
            
if(candidateMap.containsKey(candidates.Phone__c))
            
{
                
candidates.Phone__c.addError('Phone Already exists');

            }

            else

            {
                
candidateMap.put(candidates.Phone__c, candidates) ;
   
            }

        }


    }  
    
    // Using a single database query, find all the Candidate in
  
  // the database that have the same Phone address as any
  
  // of the Candidate being inserted or updated.
    
for ( Candidate__c can : [SELECT Phone__c FROM Candidate__c   WHERE Phone__c IN :candidateMap.KeySet() and Id not in :setId ] )
 
    {

        Candidate__c newCan = candidateMap.get(can.Phone__c);

        newCan.Phone__c.addError('Candidate record have already this pone number.');

    }

}
Hello guys,

I'm doing a Trigger, but since I have short experience I need some help please. I have the following Trigger that shoots when there is an attemp of insert into the custom Object. This works fine for a new record. But the logic that I'm missing is for bulk of Inserts where my Company told me that we should take the SELECT out of the loop and first build a list of the IDs and then run a single query with
IN : varibleWithIds

Here is my piece of code, how can I take the queries out of the 'for' statement and do a single 'SELECT' for the List of ids??
 
trigger AddOnlyVehiclesInStock on Order_Item__c (before insert) {
    
    // String to storage vehicle type
    Set<String> orderVehicle = 	New Set<String>();
    
    // Going through the Order_Item__c object to assign the field data to the variable orderVehicle
    for(Order_Item__c o : Trigger.New){
        orderVehicle.add(o.Vehicle_Type__c);
        
        System.debug('1-- Order_Item__c.Vehicle_Type__c: ' + orderVehicle);	
        
        	// Getting Name and quantity of the searched vehicle -- This should get the List of IDs and not loop inside a FOR
            List<Vehicle__c> v = [SELECT Name,Quantity__c FROM Vehicle__c Where Name IN : orderVehicle];
            for(Vehicle__c ve : v){
                System.debug('2-- Vehicle query debug: ' + ve);
                
                // If the vehicle that we are trying to add to the order has less than 1 in stock
                // then we cannot add it.
                System.debug('3-- Vehicle quatity: ' + ve.Quantity__c);
                
                if(ve.Quantity__c < 1){
                    o.addError('Cannot add to order vehicles without stock');
                }
            }
    }
}

Thank you!
I am getting the following error trying to Upsert to Product2: INVALID_FIELD: Field name provided, ProductCode does not match an External ID, Salesforce id, or indexed field for Product2.

ProductCode is definitely a field and it is showing as being indexed in the App Setup, Customize, Products area. What am I doing wrong!?

Note: using the SalesForce default sandbox setup - no customisations have been made.

I am sure that this is a daft newbie question, but I've been searching for ages and can't find an answer myself or an example of using upsert for Product2 that answer the question. Thanks in advance!
Hi. I'm trying to get a image to display on a Visualforce page. I have added a Static Resource, and can get it to display if I cite its name directly, but if I try to reference it using a variable, I either get an error in compilation, or a small 'dummy' image like it can't find the one I've specified.

The code that works find is as follows:

<apex:page standardController="Account">
  <apex:variable var="imageVar" value="MMC_Logo"/>
  <p>Resource name {!imageVar}</p>
<apex:image url="{!$Resource.MMC_Logo}"/>
</apex:page>

However, if I add a penultimate line of 

<apex:image url="{!$Resource.(imageVar)"/>

I get the small 'dummy' image displayed.
Surely this is just a minor syntaxical error, but nothing I have tried will work! Can someone point me in the right direction? 
Thanks..
In one of our company codes I encountered  public list<FileWrapper> listFileWrap{get;set;}  Is FileWrapper some salesforce object?
It holds records that need to be  sorted by Form_Type__c and  Form_Number__c. 
How can the sort be done? Any suggestion would be greatly appreciated.
When I am trying to fetch the Billing Address in the Account In , it gives such an error..
What is the fix for this if I have to dispaly the Account Address?

User-added image

VF Code
<apex:page controller="VFRemoteAction" sidebar="false">
  <head>
      <style>
          #errors{color:red;font-size:15px;font-style:bold;margin:5px; width:100%;}
          #result{color:green;font-size:25px;font-style:bold;margin:5px; width:100%;}
          
         
      </style>
       <script>
          var getAccount = function(){
               var accountName = document.getElementById('account_name').value;
               
               Visualforce.remoting.Manager.invokeAction('{!$RemoteAction.VFRemoteAction.getAccount}',            
               accountName,
               function(result,event){
                   if(event.status){
                  
                       document.getElementById('result').innerHTML="<p>   Name :"+result.Name+"</p>"+
                                                                    "<p>   Website :"+result.Site+"</p>"+
                                                                    "<p>   Address :"+result.BillingAddress+"</p>" ; ????????????
                   }
                   else{
                       document.getElementById('errors').innerHTML="Error --> "+event.message;
                   }
               },
               {escape: true} 
               
               );
               
               
          }
        </script>
  </head>
  <body>
      <apex:pageBlock >
          <apex:pageBlockSection title="Search for an account" columns="2">
              <div id="errors">
              </div>
              <div id="input">
                  <label>Enter the account name:</label>
                  <input type="text" name="account_name" id="account_name"/>
                  
                  <button onclick="getAccount()">Get Account</button>

              </div>
          </apex:pageBlockSection>
      </apex:pageBlock>
      <apex:outputPanel >
           <div id="result">
            
            </div>
      </apex:outputPanel>
  </body>
</apex:page>
 
I have 2 buttons that toggle between 2 different views (detail and list) of an object (ie all calls for a sales rep) using the sam Controller for both.

In the list view the sales rep or the date can be changed to retrieve for another rep or for another date. When I click the toggle button however to display the detail view again, it displays the original record selected, not the new one I selected in the list view, as the ID parameter in the URL doesn't change when I select a new record.

How do I get it to change the ID in the URL to the latest one, or to pick it up regardless of the URL parameter? In my commandbutton I put in the new ID as below, yet when it loads the detail view through the controller it loads the old one.
<apex:commandButton id="CCActivitiesView" action="{!view}" title="Call Cycle Activities View" value="Call Cycle Activities Detail View" 
        onclick="location.href=('/apex/CallCycleView?id={!CallCycle.Id}')" />
And the code in my Controller is as follows:
public CallCycleController(ApexPages.StandardController std) {

stdCtrl=std;        
CallCycle = (CallCycle__c)std.getRecord();
date ccDate = CallCycle.Date__c;

if(CallCycle != null && CallCycle.Id != null){
    CallCycle = [Select Id, OwnerId, Name, Date__c, CycleStart__c, CycleEnd__c, SalesPerson__c, SalesPerson__r.Name
                 From CallCycle__c Where Id = :CallCycle.Id];
    LoadModel();
}
I've been looking for an answer to this for a while and one person suggested 'move the redirection code into server side', but I don't know what's meant by that (have asked but no reply and am getting a bit more desperate now). 

Hello,

I cannot deploy due to this error:

The user licence doesnt allow the permission: fieldService access

How can I fix this? There is no permission already.

I am integration salesforce with SAP system using SOAP API. SAP Provided the Username and Password. So I have created a NamedCreditials in salesforce and used that in my apex class as endpoint.

like 
public String endpoint_x ='callout:SAP_Callout';

AS per salesforce doc https://help.salesforce.com/HTViewSolution?id=000003652 we have whitelisted the Salesforce IP ranges in Firewall on SAP End.
But during callout, still we are getting Error,

System.Callout Exception Unexpected end of file from server

Named Credentials: http://prntscr.com/l28ba7 

Snapshot of IP ranges which is configured in firewall.

User-added imageUser-added imageUser-added imageUser-added image
Hi,
     I have logged in as community user and try to creating the opportunity but, community user getting Insufficient privelege error while creating the opportunity. The community user have create and edit permission on account,opportunity and have edit permission on all the fields. Can any one tell me the reason why the community user getting this error?
I'm trying to create an invocable method, but I get "InvocableMethod methods do not support return type of List<List<Schema.RecordTypeInfo>>" when I try to save it. Any Ideas?
 
public class RecordTypeLookup {
    
	@InvocableMethod(label ='Get Record Types')    
    public static List<List<schema.RecordTypeInfo>> getRecordTypes(){    
    	List<List<schema.RecordTypeInfo>> wrapper = new List<List<schema.RecordTypeInfo>>();
        List<schema.RecordTypeInfo> recordTypesAvailabe = Opportunity.SObjectType.getDescribe().getRecordTypeInfos();
        List<schema.RecordTypeInfo> addRecordTypes = new list <schema.RecordTypeInfo>();
        system.debug(recordTypesAvailabe);
        for (schema.RecordTypeInfo recordTypesForProfile: recordTypesAvailabe ){
            if(recordTypesForProfile.isAvailable() && recordTypesForProfile.Name!='Master') { 
            addRecordTypes.add(recordTypesForProfile);
            }
        }
        wrapper.add(addRecordTypes);
        system.debug(wrapper);
        return(wrapper);
	}
}


 
Hi ,I have 2 objects "Positions" and "Employment Websites" having many to many relationship between them with "Job Posting" as a junction object.
->I have a case "C1" on "Position" 
->Position "P1" is posted to 3 Employement Websites "W1" ,"W2" and "W3"
->My requirement is to show case "C1" on Employement Website "W1" ,"W2" and "W3"
How can we acheive the above requirement?
If I am changing residential addresses in the contact client screen, how is it possible to view previous address that have been entered for the client? If so, where do I go to access this historical information?
Hello,
I have a custom object Journey and I have a requirement that if the journey is not exist(Journey record is not created for the day) for the day then dispaly the 'Start' button on the vf page.
Once I click on the button it'll be hidden from the page and 'Stop' button will be display on the page.


Welcome to your suggestions!

Thanks,
Nilesh
In JavaScript, For the Expression Evaluation, Eval function is there to perform the operation. In Lightning, How we can able to perform the expression evaluation. Is there any special method is there??  Please Kindly help me out regarding this??
Hi,

I am new to integration and learning from trailhead.
I came accross this doubt in REST callout chapter

Http http = new Http();
HttpRequest request = new HttpRequest();
request.setEndpoint('https://th-apex-http-callout.herokuapp.com/animals');
request.setMethod('POST');
request.setHeader('Content-Type', 'application/json;charset=UTF-8');
// Set the body as a JSON object
request.setBody('{"name":"mighty moose"}');
HttpResponse response = http.send(request);
// Parse the JSON response
if (response.getStatusCode() != 201) {
    System.debug('The status code returned was not expected: ' +
        response.getStatusCode() + ' ' + response.getStatus());
} else {
    System.debug(response.getBody());
}

this code should append the "mighty moose" to my endpoint data.
but when i open endpoint in browser data remains same.

What is going on here? am I missing any point here.

Regards,
Sagar
We recently installed a new event registration application called Fonteva. We are having a problem with reporting on complete GL Account codes. The GL Account codes are truncated in reporting and they can't seem to come up with an answer for us to alleviate this issue. So I was thinking there might be some other way of doing this through potentially using Process Builder. My idea is this.

The Description field in the Transaction object has part of the GL Account Code, lets say '42300 Workshop Income' but the complete GL Account Code should be and look like this 4233-3-35 Workshop Income. Is there a way for me to create a field that when the incomplete code '42300 Workshop Income' posts it triggers a complete code of '4233-3-35 Workshop Income' in a custom field? I was thinking maybe this could be accomplished in Process Builder. Any help would be very much appreciated
Thanks in advance.
Hello,
I have a Visualforce page that performs the following:
  • saves record
  • shows success message 
  • closes VF page
  • refreshes salesforce page
Here is a snippet of the button.
<apex:commandButton action="{!save}" value="Save" onclick="setTimeout(Closewindow, 5000)" id="saveButton" reRender="Panel" />        
            &nbsp;&nbsp;&nbsp;&nbsp;
            <apex:commandButton value="Cancel" onclick="window.close();" immediate="true"/>
            </div>
            <apex:outputPanel id="Panel" style="font-size:16px;color:red">
                <apex:messages />
            </apex:outputPanel>

The issue is that I have required fields and a message alert the user that the field is required but  the issue is that the 
onclick="setTimeout(Closewindow, 5000)"
still runs. So the VF pages closes without saving the record.
Can the values be checked prior allowing the user select the 'Save' button?

M