• sanca
  • NEWBIE
  • 40 Points
  • Member since 2014

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 16
    Questions
  • 30
    Replies
Hi Devs,

I have requirement  which goes like this ,
There is a force.com site which inserts opportunity records into sfdc system . Now Business wants to show a pop up window (notification) to all user as soon as the opportunity records gets inserted  and that pop up should have a button for user to take ownership of that record . 
Is it implementable ? Can we notify user using pop up screen ?
Hi Devs ,
I have a component which is invoked through quick action present in event record page .The component is referring to force:hasRecordId interface .
The value of recordid is resulting to  undefined  when debugged. 
<!--component>

<aura:component controller="customLookUpController" implements="flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,force:lightningQuickAction">
<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
</aura:component>

<!--controller>
({
    doInit: function(component,event,helper) {
        var getId = component.get("v.recordId");   -- > undefined 
},
})
Hi Devs ,

I have two vf page which has similar form and fields , so thinking to design a VF component and use this vf comp in both the VF pages . 
But I want to refer the apex variable of custom controller of Vf component in VF page which uses it .
Can you please tell me how to do that ?

Regards,
Sanju
I have a visualforce page:

<apex:page standardController="Quote">
<apex:form >
  <apex:pageBlock title="Teste">
      <apex:pageBlockSection title="Seção" columns="2">
          <apex:inputField value="{!Quote.Name}"/>
          <apex:inputField value="{!Quote.ExpirationDate}"/>
          <apex:inputField value="{!Quote.Status}"/>
          <apex:inputField value="{!Quote.Tipo__c}"/>
      </apex:pageBlockSection>
      <apex:pageBlockButtons >
          <apex:commandButton action="{!save}" value="Salvar"/>
          <apex:commandButton action="{!cancel}" value="Cancelar"/>
          <apex:commandButton action="{!edit}" value="Editar"/>
          <apex:commandButton action="{!delete}" value="Apagar"/>
      </apex:pageBlockButtons>
  </apex:pageBlock>
</apex:form>
</apex:page>

But it is not avaliable to use in a Opportunity button, just in a Quote button, this page will be used to create a quote from the opportunity page in Salesforce1, how do I this?
Hello guys I am trying to get the code coverage of the apex callout in rest API. Method is getting failed and I am able to achieve only 40% code coverage of the class. Please give your valuable suggestions. Thanks in advance..!


Apex Class
global with sharing class CreateCasesByContract 
{

    global static string GetToken(string userName, string password)
    {   
        string accessToken;
        Http client = new Http();
        HttpRequest req = new HttpRequest();
        req.setEndpoint('-------------------');
        req.setMethod('POST');
        string encodedBody = EncodingUtil.urlEncode('grant_type','UTF-8')+'='+EncodingUtil.urlEncode('password','UTF-8')+'&'+EncodingUtil.urlEncode('username','UTF-8')+'='+EncodingUtil.urlEncode(userName, 'UTF-8')+'&'+EncodingUtil.urlEncode('password','UTF-8')+'='+EncodingUtil.urlEncode(password, 'UTF-8');
        req.setHeader('content-type', 'application/x-www-form-urlencoded');
        req.setBody(encodedBody);
        HttpResponse res = client.send(req);
        String Token = res.getBody(); 
        system.debug('J!GS' + Token );

        JSONParser parser = JSON.createParser(Token);
        While(parser.nextToken() != null)
        {
            if ((parser.getCurrentToken() == JSONToken.FIELD_NAME)) 
            {
                String fieldName = parser.getText();
                parser.nextToken();
                if(fieldName == 'access_token')
                {
                    accessToken = parser.getText();      
                } 
            }
        }

        return accessToken;
    } 


    global  Integer CreateCase()
    {
    Integer C;
        //Make POST call for getting AssocType object 
        string assocData;
        String access_token = GetToken('API_Admin','Boxer@123');

        Http client = new Http();
        HttpRequest req = new HttpRequest();
        req.setEndpoint('------------------'+ System.UserInfo.getName() +'&caseType= 82');
        req.setMethod('GET');      
        req.setHeader('content-type', 'application/json');
        req.setHeader('Authorization', 'bearer ' + access_token);
        HttpResponse res = client.send(req);
        String assocString = res.getBody();      
        ApiResponse APIRes = new ApiResponse();

        APIRes = (ApiResponse) System.JSON.deserialize(assocString, ApiResponse.class);

        system.debug('ApiRes object '+ APIRes);
        string CID2;

        List<Contract>  ConList = [Select id,Property_Manager__c,DueDate__c,Region__c,PROPERTY_CODE__c, BP_Property__r.Name,bp_property_id__c,Region_ID__c,
                                   LeasingAgentSAM__c ,BP_Unit__r.Name from Contract where  Id =: cid and Broker_Involved__c = 'Yes'  ORDER BY LastModifiedDate  DESC  limit 1];

        List<textValuescls> txstring = New List<textValuescls>();

        string metadataValue = '';

        String CurrentUserofSFstr = UserInfo.getName();

        CaseData cd = New CaseData();


        //Mapping the Contarct data With AssocDataTypes and Passing parameters.

        ****for(AssocType AC: APIRes.ResponseContent)
        {
            for(Contract  C1 : ConList)
            {   
                CID2 = C1.Id;
                string CaseTitelstr = C1.PROPERTY_CODE__c  + '  X  '+  C1.BP_Unit__r.Name   +    'Broker Commission Request';
                if(AC.Description == 'Property')
                {
                    metadataValue += AC.AssocTypeID + ',0,' + C1.bp_property_id__c +  ',' + AC.Description + ',' + C1.BP_Property__r.Name +'|';
                }
                else if(AC.Description == 'Region')
                {
                    metadataValue += AC.AssocTypeID + ',0,' + C1.Region_ID__c + ',' + AC.Description +',' + C1.Region__c + '|';
                }
                else if(AC.Description == 'Status')
                {   
                    metadataValue += AC.AssocTypeID + ',3784,0,Status,New ';
                }
                else if(Ac.Description == 'Suite')
                {   
                    textValuescls tx1 = new textValuescls();
                    tx1.key = Ac.AssocTypeID;
                    tx1.value = C1.BP_Unit__r.Name;                    
                    txstring.add(tx1);
                }
                else if(Ac.Description == 'Due Date')
                {   
                    string duedate = string.valueOf(C1.DueDate__c);
                    textValuescls tx2 = new textValuescls();
                    tx2.key = Ac.AssocTypeID;
                    tx2.value = duedate;                    
                    txstring.add(tx2);
                }
                else if (AC.Description == 'Case Title')
                {
                    textValuescls tx3 = new textValuescls();
                    tx3.key = Ac.AssocTypeID;
                    tx3.value = CaseTitelstr;                    
                    txstring.add(tx3); 
                }
                cd.currentUser = C1.LeasingAgentSAM__c;
                cd.metaDataValues = metadataValue ;
                cd.caseNotes = 'Testing REST API from Salesforce  Please ignore this case  ' + CurrentUserofSFstr; 
                cd.textValues = txstring;
                cd.caseTitle = CaseTitelstr;
                cd.caseType = 82 ;
                cd.assignTo = 'xyz'; 
            }
        }
        //Converting  CaseData object and parameters in json fromat 
        String JSONString = JSON.serialize(cd);
        System.debug('Serialized list of invoices into JSON format: ' + JSONString);
        Http client1 = new Http();
        HttpRequest req1 = new HttpRequest();
        req1.setEndpoint('------------------------------');
        req1.setMethod('POST');      
        req1.setHeader('content-type', 'application/json');
        req1.setHeader('Authorization', 'bearer ' + access_token);
        req1.setBody(JSONString);
        HttpResponse res1 = client1.send(req1);
        string caseDataFinal = res1.getBody();
        system.debug('Final test ' + caseDataFinal);
        APIResponseCaseData APIResCaseData = new APIResponseCaseData();
        APIResCaseData = (APIResponseCaseData) System.JSON.deserialize(caseDataFinal, APIResponseCaseData.class);
        Integer caseIdFinal = APIResCaseData.ResponseContent;
        system.debug('Final test ' + caseIdFinal);
        ID coid = Id.valueOf(CID2);
        system.debug('^^^^^^^ID^^^^^^' + coid);
        List<Contract> CList = new List<Contract>();
        contract con = new Contract();
        //con.Id = coid;
        con.BCR_Case_Id__c = caseIdFinal;
        CList.add(con);
        Update CList;
    return C;
    }**
}

Mock Class :
global class CreateCasesByContractMock implements HttpCalloutMock {

    global HTTPResponse respond(HTTPRequest request) {

        // Create a fake response
        HttpResponse response = new HttpResponse();
        response.setHeader('Content-Type', 'application/json');
        response.setBody(' {"caseTitle": "4200t  X 520 Broker Commission Request ",  "caseType": 82,  "assignTo": "JigneshC",  "currentUser": "Testing"}');
        response.setStatusCode(200);
        return response; 

    }*  

}

Test Class :
@isTest Public class TestCreateCasesByContract{

    Public Static testmethod void mytest()

    {  
        Test.setMock(HttpCalloutMock.class, new CreateCasesByContractMock()); 

        HttpResponse  response = New HttpResponse ();
        test.startTest();
        CreateCasesByContract.GetToken('userName', 'password');
        test.stopTest();



    }

    public static testmethod  void testsaveDataToSF()
    {
        Test.setMock(HttpCalloutMock.class, new CreateCasesByContractMock());


        AssocType AC = New AssocType();

        test.startTest();
        CreateCasesByContract.CreateCase();
        test.stopTest();

    }**


}

 
this is my trigger:


trigger JOBTriger on Job_Application__c (after insert, after update) {
set<id> jobId = new set<id>();
set<id> contId=new set<id>();
for(Job_Application__c p : trigger.new){
      jobId.add(p.Job_Master_JObApplication__c);
      contId.add(p.Contact_Job_application__c);
 }
Map<id,Job__c> mapJobList = new Map<id,Job__c>([select Id,Job_Category__c  from Job__c where Id in : jobId]);
Map<id,Contact>mapcontactList=new Map<id,Contact>([Select ID, Bussiness__c  from Contact where id in :contId]);
List<Contact> updateToContact=new List<Contact>();

for(Job_Application__c j : trigger.new){
      Job__c jobData=new Job__c();
     Contact contData= new Contact();
   
      jobData=mapJobList.get(J.JOB_Master_JObApplication__c);
      contData=mapcontactList.get(j.Contact_Job_application__c);
      
       try{
      if(jobData.Job_Category__c !=null || jobData.Job_Category__c !=''){
        if(jobData.Job_Category__c =='Business Sale-Financial Planing'){
            if(contData.Bussiness__c==null){
              contData.Bussiness__c='Financial Planing Buyer';
              }else{
            contData.Bussiness__c= contData.Bussiness__c+';'+'Financial Planing Buyer';
            }
        
        }
        if(jobData.Job_Category__c =='Business Sale-Accounting'){
        if(contData.Bussiness__c==null){
            contData.Bussiness__c='Accounting Buyer';
            }else{
             contData.Bussiness__c= contData.Bussiness__c+';'+'Accounting Buyer';
             }

        }
        if(jobData.Job_Category__c =='Business Sale-Mortgage'){
        if(contData.Bussiness__c==null){
           contData.Bussiness__c='Mortgage Buyer';
           }else{
              contData.Bussiness__c= contData.Bussiness__c+';'+'Mortgage Buyer';
              }

        }
        if(jobData.Job_Category__c =='Business Sale-Real Estate'){
        if(contData.Bussiness__c==null){
            contData.Bussiness__c='Real Estate Buyer';
            }else{
              contData.Bussiness__c= contData.Bussiness__c+';'+'Real Estate Buyer';
              }

        }
        if(jobData.Job_Category__c =='Business Sale-Legal Firm'){
        if(contData.Bussiness__c==null){
            contData.Bussiness__c='Legal Firm Buyer';
            }else{
              contData.Bussiness__c= contData.Bussiness__c+';'+'Legal Firm Buyer';
              }

        }
        
        
        
          updateToContact.add(contData);
          }
      
      
    
      
      
 
 Upsert updateToContact;
 }
 
 
  catch(Exception e){
      System.debug(e);
      
      }
      }
   
      
  
      }


this is my test class:

@isTest
Public class TestJobApplicationn {

@isTest static void testContactt()
  {
 
          JOB__c j= new JOB__c();
        j.name='Abcc';
        j.Account__c='Jobc';
        j.Job_Category__c='Business Sale-Financial Planing';
       insert j;

 
  TerritoryPostCode__c terri= new TerritoryPostCode__c ();
        terri.Name='1100';
        terri.Main_City__c='Haldia';
        
        insert terri; 

    Contact c= new Contact();
        c.FirstName='Vi';
        c.LastName='dass';
        c.Business_Sales_Status__c='Financial Planing Buyer';
        
       c.PostCode__c=terri.id;
     
       
        insert c;
     
  

    
       Job_Application__c job= new Job_Application__c();
        job.name='TestJobApplications';
        job.Candidate__c='Ajiot ggs';
        job.Candidate_Email__c='ajs@gmail.com';
        job.Job_Title__c='Finance';
        job.Priority__c='Low'; 
        job.Contact_Job_application__c=c.id;
        job.JOB_Master_JObApplication__c=j.id;
         insert job; 
         
    } 
   
      
 }


Its give 63% covarage, but i need atlast 80%. how can i do it?
 
I would like to create a validation rule to prevent a record from being saved if the time is after X.  I have attempted this, but I can't see where I can reference the current time.  Any ideas?


AND (
ISPICKVAL (  Status__c , "Submitted" ),
Due_Date__c  =  TODAY() ,
Current time  <=  4 pm 
)
Hi All ,

I have a VF page which is a standard controller(opportunity) with extension . It has a form with some input text fields and next button ,
Next button calls pagereference method which redirects the page to std edit pagelayout of opportunity(setRedirect(false)) .In the url I have also mentioned retURL which points to the VF page .
So my query is when I fill  some text fields and clicks on next button , it redirects to opp edit page . Now when I click on cancel button, It takes me to vf page but the form values are missing . 
Can anyone tell me why the view state is missing or getting flushed out when i return back to VF page using cancel button .
Note : The form is html form , not a  <apex:form> .

As per salesforce doc , "if set to false, the redirect is a server-side forward that preserves the view state if and only if the target page uses the same controller and contains the proper subset of extensions used by the source page."

My source page is VF page (std cont -opp with ext) and target page is opportunity edit page .So here controller are the same . So it has to work as per the doc ? or am I missing something here
Hi All,

I have a VF snippet which contains input fields and call external api for autocomplete functionality. I need to display this in edit page layout . But there are 4 record types/4page layout for the object .
Is there any approach /solution where in I can display the VF snippnet in all edit page layouts or should I create 4 Vf pages to recreate 4 page layouts +to show VF snippet and choose each Vf page using record types.

Hi ,
I have created a VF page containing  form which has 4 address fields(street,city,state,country) those are populated by autocomplete functionality using 3rd party application .
I want to display this in edit page of opportunity object .
Later I knew that vf page  cannot be placed in edit page layout .
So I looked into button overriding options , But there is a issue  , The opportunity object has 4 record types/4 page layouts .
If I override the new / edit button with the automplete VF page along with other input fields(replicate edit pagelayout fields)  , the display would be same irrespective of record types .
This will cause a mismatch in fields display or page layouts will be ineffective .

1) So for edit functionality , should I create 4 apex pages to display  fields form 4 correspodning page layouts and check which record type is checked , So the Vf page can be dynamically choosen ?
2) And what about autocomplete VF page? since this functionality is common , Can I convert this Vf page to VF component ,so It can be used in all 4 page layouts?
Regarding the 

Hi,

I have managed package installed in ord and accessing the web service from mobile app.

As I am new to managed package hence could someone help on below queries:
So from where we can check that what type of web service is used, what are method or input/output of the web service method.
Can we able to download the wsdl from managed package?

Thanks
Preyanka