• gbu.varun
  • SMARTIE
  • 640 Points
  • Member since 2012
  • Manager
  • Genpact

  • Chatter
    Feed
  • 21
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 21
    Questions
  • 158
    Replies

Hi All ,

Let me explain my issue here ,

 

I have 2 objects lets say Account , contact .

 

I have to create a list button for "Contact" related list on account object , so when i select some records and hit "List Button" it should navigate me to new page where it should consist the information of selected records one after another . if  i modify any record field values and hit "save" button , it should save the records & navigate me to Parent Account record with contact related list updated

 

Thanks in advance if you trying to help me

 

Prathap

Hi all,

I'm trying to create a batch apex to capture system generated lastlogindate on to custom field.But this is firing an error.

Here is the code

global class CaptureLastLoginDate implements Database.Batchable<sObject>{
 
    //This is the query that is passed to the execute method.  .
    
    String query = 'SELECT id, LastLoginDate FROM User WHERE Id=:UserInfo.getUserId()';
 
    global database.queryLocator start(Database.BatchableContext BC) {
        return database.getQueryLocator(query);
 
    }
    //close start method
 global void  Execute(Database.BatchableContext BC, List<User> scope) {
 User u = [SELECT id, LastLoginDate FROM User WHERE Id=:UserInfo.getUserId()];
 
      
       // Iterate through the whole query
        for(User a : scope) {
            
                a.LastLoginDate__c = u.LastLoginDate;
            } //close if statement
         update LastLoginDate__c;
         }
        
        //close for-loop
      
     //close execute method
 
    global void finish(Database.BatchableContext BC) {
 
        
    } //close finish method

 

Could anyone help me.Thank you in advance

error:

Error: Compile Error: Argument type of global method must also be global: LIST<User> at line 12 column 15

 

My apex class -only covered 36%.Please help me-get more coverage(above 75%).....

APEXCLASS:

 

global class populatevatimesheetrepository implements Schedulable
{
  public integer inscount=0;
  public integer updtcount=0;
  public integer rcnt;
  public string randomgen;
  Public Date mydate{get;set;}
  public String sdate {get;set;}
        
  global void execute(SchedulableContext SC)
  {
    
    list<VATimesheet__c> va1 = new list<VATimesheet__c>();
    list<VAtimesheetRepository__c> va2 = new list<VAtimesheetRepository__c>();
    list<VATimesheet__c> va3 = new list<VATimesheet__c>();
    list<VAtimesheetRepository__c> va4 = new list<VAtimesheetRepository__c>();
        
    //** random no logic
    
    integer va1count=[select count() from VATimesheet__c where Status__c='Processed' and ( BackUpID__c = NULL or Backupid__c = '' ) ];

below  red lines  are not coverd…..
    if (va1count > 0)
       
       { 
         system.debug('value of count:'+va1count);      
         DateTime dT = System.now();
         myDate = date.newinstance(dT.year(), dT.month(), dT.day());
         sdate = String.valueOf(myDate);
         do 
            {
                 system.debug('coming to calculate random number');
                 double d=math.random()*2;
                 randomgen=sdate+ '-' + string.valueof(d.intvalue());
                 system.debug('the random number value is:'+randomgen);
                 rcnt = [ select count() from vatimesheet__c where backupid__c = :randomgen];
             }
         while(rcnt > 0);
         
         va1=[select id,AccountId__c,AccountName__c,AcctID__c,Aname__c,BackUpID__c,BCRNo__c,BCRRecID__c,
                     Billed_Hrs__c,Contract_Hours__c,chrs__c,Job_type__c,OT_Hrs__c,VAId__c,Payrollno__c,
                     Payroll_status__c,srchstring__c,Status__c,TimeCardDate__c,Type__c,VA__c,VAName__c,
                     Vname__c from VATimesheet__c where Status__c='Processed' and (BackUpID__c=NULL or Backupid__c = '')];
         for(VATimesheet__c vt:va1)
            {
              system.debug('The backup id value is :' + randomgen);
              
              //***updating time sheet object
              vt.BackUpID__c=randomgen;
              va3.add(vt); 
              
              //** inserting into timesheet repository
               va2.add(new VAtimesheetRepository__c(AccountId__c=vt.AccountId__c,Aname__c=vt.Aname__c,BackUpID__c=vt.BackUpID__c,BCRNo__c=vt.BCRNo__c,
                      BCRRecID__c=vt.BCRRecID__c,Billed_Hrs__c=vt.Billed_Hrs__c,Contract_Hours__c=vt.Contract_Hours__c,Job_type__c=vt.Job_type__c,
                      OT_Hrs__c=vt.OT_Hrs__c,VAId__c=vt.VAId__c,Payrollno__c=vt.Payrollno__c,Payroll_status__c=vt.Payroll_status__c,
                      Status__c=vt.Status__c,TimeCardDate__c=vt.TimeCardDate__c,Type__c=vt.Type__c));
            }
         insert va2; 
         system.debug('the row is inserted');
         update va3;
         system.debug('the row is updated');
         savepoint sp=database.setsavepoint();         
         integer vtcnt = [ select count() from vatimesheet__C where backupid__c = :randomgen ];
         integer vtrcnt = [ select count() from vatimesheetrepository__C where backupid__c = :randomgen ];
                 
         try
           {
             system.assertequals(vtcnt,vtrcnt);
              
             } 
          catch(exception e)
            {
              database.rollback(sp);
             }
                       
                   
       }
     
  }    
}

--------------------------------------------------------------------------------------------------------------------

testclass:

@isTest(seealldata=true)
private class VAtimesheetRepository1
{
  //*****************************************************************************
  //** this Test class will test the VAtimesheet and VAtimesheetRepository      *
  //*****************************************************************************
   public static String CRON_EXP = '0 0 0 22 5 ? 2020';
    
    
  Public static testmethod void m0()
    {
        account a1 = new account();
     a1.name = 'AA';
     insert a1;
         
     our_va__c v1 = new our_va__c();
     v1.name = 'v1';
     insert v1;
     
     contact c1= new contact();
     c1.LastName='cccccc';
     c1.Accountid=a1.id;
     c1.Primarycontact__c=true;
     insert c1;
         
     vatimesheet__c  v2 = new vatimesheet__c();
     v2.TimeCardDate__c= date.parse('8/10/2013'); 
     v2.Status__c='Processed';
     v2.Type__c='Working';
     v2.AccountId__c=a1.id;
     v2.VAId__c=v1.id;
     v2.OT_Hrs__c= 0; 
     v2.Billed_Hrs__c=5.0;
     v2.BackUpID__c=NULL;
     insert v2;
    
      
    VAtimesheetRepository__c v3= new VAtimesheetRepository__c();  
    insert v3;  
              
      String jobId = System.schedule('ScheduleApexClassTest', CRON_EXP, new populatevatimesheetrepository());
       CronTrigger ct = [SELECT Id, CronExpression, TimesTriggered, NextFireTime FROM CronTrigger WHERE id = :jobId];
         //Verify the expressions are the same
        System.assertEquals(CRON_EXP,ct.CronExpression);
         //Verify the job has not run
        System.assertEquals(0,ct.TimesTriggered);
          //Verify the next time the job will run
        System.assertEquals('2020-05-22 00:00:00',
       String.valueOf(ct.NextFireTime));     
    
       } 
       
 }
  • December 05, 2013
  • Like
  • 0

Please find below code is fetching the user's time off based on ownerid and user market. Some time we are getting the wrong datas like fetching the datas only based on the market. 

 

for(Working_Days__c wd : [select Id,User__c,Start_Date__c,End_Date__c,Expired__c,Market__c,RecordTypeId,Reason__c,Time__c,
M_AM__c,M_PM__c,Tu_AM__c,Tu_PM__c,W_AM__c,W_PM__c,
Th_AM__c,Th_PM__c,F_AM__c,F_PM__c,Sat_AM__c,Sat_PM__c,
Sun_AM__c,Sun_PM__c
from Working_Days__c
where Expired__c = false and (User__c = :ownerId or Market__c = :userMarket)  order by Time__c asc nulls last])

 

Expectation:

 

we are planning change the condition " where Expired__c = false and (User__c = :ownerId or (Market__c = :userMarket AND RecordTypeId= 'Company_Holdidays' "

 

But, we are facing problem in "  RecordTypeId= 'Company_Holdidays' " , please help me how to define and excute the same. 

hi

 

 

from a list iam getting a date  how to find day of week for particular date using apex class

Hello Helpers

 

It is possible  to add scrollBar  to apex:pageBlockTable?

 

thanks in advance

csbaa

  • November 16, 2013
  • Like
  • 0

I'm trying to generate Apex code from a WSDL and getting this error in Development environment: (I deleted the url)

 

Error: Failed to parse wsdl: Found schema import from location https://         External schema import not supported

 

I compare the WSDL I have in Dev with the one we are currently using in Production and they are the same.

 

I would appreciate any comment/suggestion why this is not working, thank you!!!

  • November 12, 2013
  • Like
  • 0

Hi,

I am trying to setup a functionality when the user creates a child record from the child related list on the parent page,
some fields in the child record get prepopulated with the details from the parent record. I am having no issues doing this.
However the user should be able to change the parent (lookup field) from the child record and when the user does that I have a button that updates the child record fields with the new parent information.

I keep getting an Attempt to dereference a null object error.

Can someone please point out any corrections that I can do to my code to make it work.


public class Test_Controller {
    public Test_Controller(ApexPages.StandardController controller) {
    Child__c child = (Child__c)controller.getRecord();
        if (child.parent__c != null) {
            Parent__c parent = [select Name__c, TField1__c, FROM Parent__c  
                                                  WHERE id =: child.parent__c limit 1];

            child.parent__c = parent.Id;
            child.Name__c = parent.Name;
            child.TField1__c = parent.TField1__c;

        }
    }
 
    public PageReference UpdateParentInfo(){
        child = (Child__c)std.getRecord();
            List<Parent__c> parent = [SELECT Name__c, TField1__c, FROM Parent__c  
                                                      WHERE id =: child.parent__c];
        
            if(!parent.isEmpty()){
                child.Name__c = parent.get(0).Name;
                child.TField1__c = parent.get(0).TField1__c;
           
            }

    }
}


I have Contact as master and  policy as detailed. i want retrive records other than this list..

 

List<contact> cp = [select id,Customer_Producer__c from contact];  //this is contact List

 

List<Policy__c> pList1 = [select id,IssueDate__c from Policy__c where Contact_1__c IN: cList]; // Records of policy under contact


List<Policy__c> pList2 = [select id,IssueDate__c from Policy__c where Contact_1__c IN: cList And NotIn pList1]; // I want to retrive otherthan records of pList1. I have written for just to understand.

 

 

 

  • October 29, 2013
  • Like
  • 0

hi,i installed force.com ide ...after completion of that i got below error....

java terminated .exit code=-1

 

Hi, I am new to SFDC. I am having a trigger which is updating the fields in a Parent__c object after any  update to the Child__c object .There is no Master Detail Relationship just reffering Parent- Child  for ease to understand. 

These objects having a Lookup relation Lookup_Name__c.

 

These fields count the number of Child__c Object for different Status__c.

 

I want this trigger to fire only when there is a change n the status of the Child__c.Status__c object  or else do not take any action. Hence need to compare the old and new values.

 

Here is the code. Need help. Thanks in Advance.

=================================================

 

trigger CountTrigger on Child_Obj__c (before update) {

Set<Id> parentIds = new Set<Id>();

List<Parent_Obj__c> parents = new list<Parent_Obj__c>();

if (Trigger.isDelete){

 for(Child_Obj__c child:Trigger.oldMap.values()){

    parentIds.add(child.Lookup_Name__c);

   }

}

else{

for(Child_Obj__c child:Trigger.new){

   parentIds.add(child.Lookup_Name__c);

   }

}

List<Id> listParents = new List<Id>();

for (Id parentId : parentIds) {

  listParents.add(parentId);

  }

  Parent_Obj__c parent=

   [SELECT Id, Total_Count__c, A_Count__c FROM Parent_Obj__c WHERE Parent_Obj__c.Id in: listParents limit 1];

 parent.Total_Count__c =

    [SELECT COUNT() FROM Child_Obj__c WHERE Lookup_Name__c in: listParents ];

  parent. A_Count__c=

    [SELECT COUNT() FROM Child_Obj__c WHERE Lookup_Name__c in: listParents AND Status__c='A'];

  parent.B_Count__c =

    [SELECT COUNT() FROM Child_Obj__c WHERE Lookup_Name__c in: listParents AND Status__c='B'];

 parent.Total_Count__c = parent. A_Count__c + parent. B_Count__c;

parents.add(parent);

 update parents;

}

===========================================================

 

  • September 26, 2013
  • Like
  • 0

Hi Team,

 

we have written a javascript in visualforce page. how to get the variables "latitude" and "longitude" from it.

 

<script>
function xyz(){
if(navigator.geolocation)
{
navigator.geolocation.getCurrentPosition(showPosition);
}
}
function showPosition(pos){
var latitude=pos.coords.latitude;
var longitude=pos.coords.longitude;
}

</script>

 

Thanks,

Anil

how can i call script in class?

 

if i have this code:

<script>
    function clearValue() {
    document.getElementById('{!$Component.page:frm:pblck:pbSectn:pbSitemLookup:accountLookup}').value = '';
    document.getElementById('{!$Component.page:frm:pblck:pbSectn:pbSitemLastName:contactLastname}').value = '';
  
    alert();
    return false;
    }
    
    </script>

 

how can i call this in the controller/apex class?

  • September 19, 2013
  • Like
  • 0

I have and PHP code for accessing the FluidSurvey API. anyone who can give me its APEX alternative or convert the code into apex.. i will be thankful

 

 

<?php
function GET($url){
        global $api_key, $password;
        $curl = curl_init();
        curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
        curl_setopt($curl, CURLOPT_USERPWD, $api_key.':'.$password);
        curl_setopt($curl, CURLOPT_SSLVERSION,3);
        curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
        curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 2);
        curl_setopt($curl, CURLOPT_HEADER, false);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($curl, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible;
                MSIE 5.01; Windows NT 5.0)");
        curl_setopt($curl, CURLOPT_URL, $url);
        $data = curl_exec($curl);
        curl_close($curl);
        return $data;
}
  • April 17, 2013
  • Like
  • 0

hi, 

 

i have a requirement that , the field X  data type is "text" that holds values.

 

but in my Visual Force page the values in X  that has text datatype  should be displayed in "radio button" or  " check box". based on the picklist value.

 

pls help me to achieve this..

 

Thanks in advance.

I need to insert a record into a custom object on save in opportunity.  Here is my trigger:

 

trigger AddSRSplit on Opportunity (after insert) {       

 

      for (Opportunity o : Trigger.new) {    

          

      Sales_Rep_Split_Revenue__c Split= new Sales_Rep_Split_Revenue__c         

           

                   ( Name = 'No Split',          

                     opportunity__C = o.ID,          

                     Split__c = 100,                        

                     Sales_Rep__c = o.owner);   

       insert Split;                                   }                                                

                                                                         }

 

 

The problem is that I can not get the opportunity owner to be the sales rep name in the custom object, it keeps failing saying that an ID is expected.  Any help would be appreciated!

 

 

 

How can we use publish-subscriber event pattern in Community Cloud using lightining web component.
I have drag-and-drop two Lightining Web Component(LWC) in a community page. On click on first component I have to show some output in second component.
Same components are working in Lightning Page(Like: Account detail page) but not in Community page. I used pubsub module from the lwc-receipe for this.
In  my Lightning Web Component I am using below code 

import { CurrentPageReference } from 'lightning/navigation';
@wire(CurrentPageReference)
pageRef;


I am getting value from the pageRef in Lightning Page but when I used same component in community it is returning undefined.

how can we get current page reference in community when we use Lightning Web Component.
Trigger has limitation of the 100 SOQL records. It will exceed the SOQL query limit if more than 100 SOQL quries are made. 
In the second example of the documentation following line is mentioned:
If more than 20 records are pulled into this request, the trigger would exceed the SOQL query limit of 100 SELECT statements:
trigger MileageTrigger on Mileage__c (before insert, before update) {
   for(mileage__c m : Trigger.new){ 
      User c = [SELECT Id FROM user WHERE mileageid__c = m.Id];
   }
}

But it will count only 20 soql queries so it should not exceed the limitation.
 
Hi,

I am developing Hybrid application to work offline. 
I am running Account Editor Sample application. After some time when security token become expires and application calls  following function of the this file cordova.force.js :
var forcetkRefresh = function (forcetkClient, success, fail) {
        authenticate(function(oauthResponse) {
            var oauthResponseData = oauthResponse;
            if (oauthResponse.data)  {
                oauthResponseData = oauthResponse.data;
            }
            forcetkClient.setSessionToken(oauthResponseData.accessToken, null, oauthResponseData.instanceUrl);
            success();
        },
        error);
    };

And It returns error. Please help to resolve this error. App is not refreshing access_token.
Hi,

I am creating a Hybrid app for Android application. I installed Forcedroid Package from Github. There are some hybrid sample apps like: AccountEditor, ContactExplorer etc. I also created a new application. Everything is working fine. It has offline feature also.
But after sometime application stop working. I got uncaught error.
After deleting the cache and data of the application app asks for Salesforce username and password. And app start working again without making any coding change.

I think it is authentication issue due to Salesforce SDK. it does not refresh access token.
Can anyone help on this issue please?

It is my bootcnfig setting:
{
    "remoteAccessConsumerKey": "Salesforce Consumer Key",
    "oauthRedirectURI": "URL",
    "oauthScopes": ["api","web"],
    "isLocal": true,
    "startPage": "index.html",
    "errorPage": "error.html",
    "shouldAuthenticate": true,
    "attemptOfflineLoad": true
}

Hi,

 

I am running a code for streaming API. I am able to run it in my Developer edition. When I am trying to run it in anothe Developer edition I am not able to run streaming API.

I got problem. Code is not executing following line

 

$.cometd.init({url: window.location.protocol+'//'+window.location.hostname+'/cometd/24.0/',requestHeaders: { Authorization: 'OAuth {!$Api.Session_ID}'} });

 

Is there any work around?

I think error is at  this section:

requestHeaders: { Authorization: 'OAuth {!$Api.Session_ID}'     

Hi,

 

I have developed a VF for Streaming API which is working fine in developer edition. When I am running same code in another developer edition it is not running. I think there is some setting missing. Please help me.

 

<apex:page >
    <apex:includeScript value="{!$Resource.cometd}"/>
    <apex:includeScript value="{!$Resource.jquery1}"/>
    <apex:includeScript value="{!$Resource.json2}"/>
    <apex:includeScript value="{!$Resource.jquery_cometd}"/>
    <script type="text/javascript">
        (function($){
            $(document).ready(function() {
                // Connect to the CometD endpoint
                $.cometd.init({
                url: window.location.protocol+'//'+window.location.hostname+'/cometd/24.0/',
                requestHeaders: { Authorization: 'OAuth {!$Api.Session_ID}'}
                });
                // Subscribe to a topic. JSON-encoded update will be returned
                // in the callback
                $.cometd.subscribe('/topic/Push', function(message) {
                $('#content').append('<p>Notification: ' +
                'Channel: ' + JSON.stringify(message.channel) + '<br>' +
                'Record name: ' + JSON.stringify(message.data.sobject.Name) +
                '<br>' + 'ID: ' + JSON.stringify(message.data.sobject.Id) +
                '<br>' + 'Event type: ' + JSON.stringify(message.data.event.type)+
                '<br>' + 'Created: ' + JSON.stringify(message.data.event.createdDate)
                +
                '</p>');
                });

            });
        })(jQuery)
    </script>
    
    <body>
        <div id="content">
            <h1>Streaming API Test Page</h1>
            <p>This is a demonstration page for Streaming API. Notifications from the
            InvoiceStatementUpdates channel will appear here...</p>
        </div>
    </body>
</apex:page>

 

 

 

Hi,
 
Can a Visualforce page be refreshed when a webservice is invoked. If it is possible how can I achieve this.

Hi All,

 

Is there any way to open a pop-up by web service or Apex class??

I have to integrate CTI system with Salesforce. I have installed open CTI from following link.

http://wiki.developerforce.com/page/Open_CTI#Installing_The_Demo_Open_CTI_Adapter

 

Can anyone guide me How can I configure it with my CTI System? I have simple requirement. I have to open relative account page as a pop up when a call is reached at CTI System.Please help.

Hi,

 

I have to develope a CTI adapter. Currently, I am using Demp CTI adapter. I have to disable call functionality from Salesforce. How can I disable call from Salesforce. I need only Incoming call.

 

Hi All,

 

I am using some javascript.

I am opening a VF page as pop-up. I have some requirement.

When a user close pop-up parent should be refreshed and a parameter should be pass to parent window.

This is my Jscript

 

        <script>
            window.onunload = window.onbeforeunload = refreshParent;
            function refreshParent(){
                    var v = document.getElementById('pgId:frmId:CheckinID');                  
                    window.opener.location.href= window.opener.location.href+"?checkinDate="+v.value+"";                   
            }
        </script>

 

Problem is pop-up is refreshing many time and it put check-inDate many times in url.

Can anyone help me please to update check-in time of parent window.

 

 

 

 

i am trying to Build a CTI Connector Solution in Visual Studio 2008 using CTI Toolkit 4.03. i got an error Error 1 error C2259: 'ATL::CComObject' : cannot instantiate abstract class c:\program files (x86)\microsoft visual studio 9.0\vc\atlmfc\include\atlcom.h 1801 while compiling after step( Adding a COM Base Class to a CTI Adapter Project). please help!!!

Hi I have to connect Salesforce with a CTI system.

I have downloaded CTI toolkit. I have Visual Studion 2003,  Visual Studion 2008 and Visual Studion 2010 also. I read in the CTI workbook to use VS2003, But when I am using  VS 2003 to change demo adapter, it is giving error that your project is built in newer version.

 

 

I am able able to connect demo adapter with salesforce. My question is regarding CTI System. My CTI system is providing XML to us. Which class will take this XML as input and it will parse it to salesforce. I want to get telephone number into Salesforce.

 

I am facing problem to connect CTI system with CTI adapter.

 

I am facing a sorting problem. I am using order by CreatedDate command which is working in sandbox but not in Production. 

 

Code :

List <Lead> ld1 =[Select id,Name from lead where id IN:ld order by createddate desc limit 2000 ];
    
public Lead[] getNumbers() {
	try {
		Lead[] numbers = [select Name  from Lead where id IN:ld1 order by createdDate asc limit :list_size  offset :counter];
		return numbers; 
	} 
	catch (QueryException e){
		ApexPages.addMessages(e);
		return null;
	}
}

 

Hi All,

 

On Account page activity history I need to open edit link into a new Tab. How can I achieve it?

 

Thanks,

 

Hi All,

 

 

I want to get records of a particular list view in controller like I can get records of a particular view on visualforce force page as:

 

<apex:page standardController="Account" >
    <apex:enhancedList height="300" rowsPerPage="10" Listid="00B90000003eOf9">       
</apex:page>

 

 

00B90000003eOf9  is the id of list view.  I want to get record these records into a list in Controller. How can I do it?

Hi All,

 

 

I am working on Partner portal. Accounts are visible to all users. I want to show activity history only to account owner. If a partner is not an owner of the account, in this case activity list should be invisible for that user. 

 

It can be through custom visualforce page as a related List of activity history. Is there any other idea to do it.??

Hi,

 

I am creating an account and its associated contact and sending an email to contact with an attachment saying "Hello

Contact-Name". 

 

I am able to send an pdf with "Hello" but if tried to send "Hello-Contact-Name" then I am able to send a pdf Saying "Hello Contact-Name"  but mailed pdf is currupted.

 

For Attchment I created a pdf from another page "PdfPage" which renderAs="PDF"   and Contact is standardController for this page.

 


Code for generating pdf is as:

 

        PageReference pdf = Page.PdfPage;

        pdf.getParameters().put('id',(String)contactID);

      Blob blobContent;
        try{
            blobContent = pdf.getContent();
        System.debug(blobContent.size());
        }
        catch(Exception e){
            blobContent = Blob.valueOf('Some Text');

        Messaging.EmailFileAttachment attachment = new Messaging.EmailFileAttachment();
        attachment.setFileName('Invoice.pdf');
        attachment.setbody(blobContent);

        mail.setFileAttachments(new Messaging.EmailFileAttachment[] {attachment});

 

Hi,

 

I am invoking a php web service though apex code. I am able to invoke my php web service by php client but I am not able to invoke it through apex.  I am setting header for authentication as :

 

        HttpRequest req = new HttpRequest();
        req.setEndpoint('http://serverurl/file.php?wsdl');
        req.setMethod('GET');
        Blob headerValue = Blob.valueOf(username + ':' + password);
        String authorizationHeader = 'Basic '+ EncodingUtil.base64Encode(headerValue);
        req.setHeader('Authorization', authorizationHeader);
        req.setHeader('Content-Type', 'application/soap+xml');

 

I am able to get  soap (wsdl) by "System.debug(res.getBody()); " command but   I am getting following error "System.CalloutException: Web service callout failed:"   

My webservice.invoke method is as:

            WebServiceCallout.invoke(
              this,
              request_x,
              response_map_x,
              new String[]{endpoint_x,
              'http://test-uri/soap/export/getUsers',
              'http://test-uri/soap/export/',
              'getUsers',
              'http://test-uri/soap/export/',
              'getUsersResponse',
              'testUriSoapExport.getUsersResponse_element'}

            );

 

Is this error due to authentication ?  How can I resolve it ?

 

Thanks,

Varun

 

Hi,

I am developing Hybrid application to work offline. 
I am running Account Editor Sample application. After some time when security token become expires and application calls  following function of the this file cordova.force.js :
var forcetkRefresh = function (forcetkClient, success, fail) {
        authenticate(function(oauthResponse) {
            var oauthResponseData = oauthResponse;
            if (oauthResponse.data)  {
                oauthResponseData = oauthResponse.data;
            }
            forcetkClient.setSessionToken(oauthResponseData.accessToken, null, oauthResponseData.instanceUrl);
            success();
        },
        error);
    };

And It returns error. Please help to resolve this error. App is not refreshing access_token.
Hi
I have latest version of salesforce cli and running sfdx plugins --core returns 
@salesforce/plugin-generator 0.0.10 (core)
@salesforce/sfdx-trust 1.0.8 (core)
builtins 1.0.0 (core)
salesforcedx 43.12.0 (core)

But  when I run  sfdx plugins:install salesforcedx@latest I get errors below:
Installing plugin salesforcedx...
Installing plugin salesforcedx... Checking for digital signature.
Successfully validated digital signature for salesforcedx.
Finished digital signature check. Installing... !
 !    yarn --non-interactive --mutex=file:C:\...\AppData\Local\sfdx\yarn
 !    --cache-folder=C:\Users\...\Local\sfdx\yarn exited with code 1
 !    warning salesforcedx > salesforce-alm > replace > minimatch@0.2.14: Please update to minimatch
 !    3.0.2 or higher to avoid a RegExp DoS issue
 !    warning salesforcedx > force-language-services > salesforce-alm > webdriverio > archiver > glob >
 !    minimatch@2.0.10: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
 !    warning salesforcedx > salesforce-alm > replace > nomnom@1.6.2: Package no longer supported.
 !    Contact support@npmjs.com for more info.
 !    warning salesforcedx > force-language-services > salesforce-alm > webdriverio > request >
 !    node-uuid@1.4.8: Use uuid module instead
 !    warning salesforcedx > salesforce-alm > jsonwebtoken > joi > hoek@2.16.3: The major version is no
 !    longer supported. Please update to 4.x or newer
 !    warning salesforcedx > force-language-services > salesforce-alm > webdriverio > request > hawk >
 !    hoek@0.9.1: The major version is no longer supported. Please update to 4.x or newer
 !    error An unexpected error occurred: "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.1.tgz:
 !    Request failed \"503 Service Unavailable\""
Below is the code sample I'm trying to put in a controller extension class. However, I'm getting "variable does not exist: opp.id" error at line 13. The actual code makes a http callout to an external service. I'm trying to write code to make a javascript remoting call on click of a button from a VF page. Could you please help
 
public class TestPageEx {
    private final Opportunity opp;
    // The extension constructor initializes the private member
    // variable acct by using the getRecord method from the standard
    // controller.
    public TestPageEx(ApexPages.StandardController stdController) {
        this.opp = (Opportunity)stdController.getRecord();
    }
    
    @RemoteAction
    public static String aaExample(String s)
    {
        Attachment att=   [Select Id,ParentId, Name,body,ContentType From Attachment where ParentId = :opp.Id limit 1];

}

}

Thanks.
I am making a callout and then trying to insert the data and then immediately I make another callout followed by insert operation.  This process continues for users matching my criteria.  How to avoid below exception?

I know that its not allowed to do a callout and a DML in series.  But as per the requirement I need to follow this process.  

System.CalloutException: You have uncommitted work pending. Please commit or rollback before calling out

Note: I cannot use future method since I am running this process in a batch class.
 
Hi there,

I have an Apex Rest Webservice that I need to call but without oAuth. I want to use my username and password to authenticate. Is this possible? If yes, how can I do this? Assume that I will be calling this from either Java or C#. Thanks.

SS.

 
I am always getting the following message from Streaming API workbench (https://workbench.developerforce.com/streaming.php)

{  "channel": "/meta/handshake",   "advice": {    "reconnect": "handshake"  },   "error": "403::Server is too busy. Please try your request again later.",   "successful": false,   "id": "4",   "action": "handshake"}

Is there anyone from Salesforce.com Support that can check this.
 
how to find profile name of current user in trigger and how to write the test class for that trigger
I am planning to develop a hybrid remote mobile app using forcedroid. As per my understanding; hybrid remote will use the visual force pages which will be hosted on cloud. I want that application to have ofline capabilities like user should be able to use the application with last data which was downloaded while he was online.
If hybrid remote can leverage offline capabilities; then I wonder how does the app render the visualforce page which is hostd on cloud.
What is the best way to build a bybrid app?

Hybrid apps are built using HTML5 and JavaScript wrapped inside a thin container that provides access to native platform features. For the most part, hybrid apps provide the best of both worlds, being almost as easy to develop as HTML5 apps with all the functionality of native. In addition, hybrid apps can use the SmartSync Data Framework in JavaScript to model Salesforce data, query and search it, edit it, securely cache it for offline use, and synchronize it with the Salesforce server.
You know that native apps are installed on the device, while HTML5 apps reside on a Web server, so you might be wondering whether hybrid apps store their files on the device or on a server? You can implement a hybrid app locally or remotely.

Local

You can package HTML and JavaScript code inside the mobile application binary, in a structure similar to a native application. In this scenario you use REST APIs and Ajax to move data back and forth between the device and the cloud.

Server

Alternatively, you can implement the full web application from the server (with optional caching for better performance). Your container app retrieves the full application from the server and displays it in a browser window.
I am trying to build a test app with Mobile SDK in eclipse, I've managed all the steps and I don't see errors in the project. But when I try to run my application on a virtual device, I get this error:

04-07 12:11:53.251: I/dalvikvm(933): Failed resolving Lcom/fnr/test/KeyImpl; interface 11 'Lcom/salesforce/androidsdk/app/SalesforceSDKManager$KeyInterface;'

In Eclipse I have my test project, a project with SaesforceSDK and a project with SmartStore. The dependencies are marked via Properties -> Android -> Library. For what I see in my test project there is a KeyImpl.java file indeed in the package.

Have you faced this problem? Thanks in advance
T.

Hi,

I am creating a Hybrid app for Android application. I installed Forcedroid Package from Github. There are some hybrid sample apps like: AccountEditor, ContactExplorer etc. I also created a new application. Everything is working fine. It has offline feature also.
But after sometime application stop working. I got uncaught error.
After deleting the cache and data of the application app asks for Salesforce username and password. And app start working again without making any coding change.

I think it is authentication issue due to Salesforce SDK. it does not refresh access token.
Can anyone help on this issue please?

It is my bootcnfig setting:
{
    "remoteAccessConsumerKey": "Salesforce Consumer Key",
    "oauthRedirectURI": "URL",
    "oauthScopes": ["api","web"],
    "isLocal": true,
    "startPage": "index.html",
    "errorPage": "error.html",
    "shouldAuthenticate": true,
    "attemptOfflineLoad": true
}

Hi all,

I'm trying to create a batch apex to capture system generated lastlogindate on to custom field.But this is firing an error.

Here is the code

global class CaptureLastLoginDate implements Database.Batchable<sObject>{
 
    //This is the query that is passed to the execute method.  .
    
    String query = 'SELECT id, LastLoginDate FROM User WHERE Id=:UserInfo.getUserId()';
 
    global database.queryLocator start(Database.BatchableContext BC) {
        return database.getQueryLocator(query);
 
    }
    //close start method
 global void  Execute(Database.BatchableContext BC, List<User> scope) {
 User u = [SELECT id, LastLoginDate FROM User WHERE Id=:UserInfo.getUserId()];
 
      
       // Iterate through the whole query
        for(User a : scope) {
            
                a.LastLoginDate__c = u.LastLoginDate;
            } //close if statement
         update LastLoginDate__c;
         }
        
        //close for-loop
      
     //close execute method
 
    global void finish(Database.BatchableContext BC) {
 
        
    } //close finish method

 

Could anyone help me.Thank you in advance

error:

Error: Compile Error: Argument type of global method must also be global: LIST<User> at line 12 column 15

 

Hello guys,

 

I am a newbie in apex development. Can you please help if you have any solution as per my code below?

 

I have a .NET web page (ASPX page) that reading a pdf file in webserver and write to HttpResponse as binary as following. The ASPX page using a hash key as a query string parameter to authenticate the valid request. The following 

 

Dim FullPath As String = Server.MapPath(ModuleURL)
Dim content() As Byte = Utilities.ReadBinaryFromFile(FullPath)

Response.ClearHeaders()
Response.ClearContent()
Response.ContentType = "application/pdf"
Response.AddHeader("Content-Disposition", "inline; filename=" & Path.GetFileName(FullPath))
Response.BinaryWrite(content)
Response.End()

 

If I open that on Chrome/IE, the requested pdf file opens correctly.

 

I am trying to use Apex callout and capture the pdf file as a Blob and display the Blob content as pdf in a Visualforce page as following:

 

Visualforce page:

 

<apex:page sidebar="false" showHeader="false" controller="TestGenContentController" contentType="application/pdf">

          <script>
                window.location.href = "data&colon;application/pdf;base64,{!ContentFile}";
          </script>

</apex:page>

 

Controller:

 

public class TestGenContentController {
Public String getContentFile(){
Http h = new Http();
HttpRequest req = new HttpRequest();
HttpResponse res = new HttpResponse();

req.setEndpoint(contentURL);
req.setMethod('GET');
req.setHeader('content-type', 'application/pdf');

//invoke Http request
res = h.send(req);
Blob retBlob = res.getBodyAsBlob();
String retContentFile = EncodingUtil.base64Encode(retBlob);

return retContentFile;

}

 

I alway get incorrect format of the pdf file when executing the visualforce page.

 

 

If I change the statement:

Blob retBlob = res.getBodyAsBlob();

 

to:

String retData = res.getBody();

System.Debug(strData);

 


The debug log in the body of the Respone is as follow:

 <html><head><title>Object moved</title></head><body><h2>Object moved to <a href="/aspx/Pdf/RiskProfileDefinitions.pdf">here</a>.</h2></body></html>

 

Thanks.

 

 

 

 

 

 

 

 

 

  • December 11, 2013
  • Like
  • 0

Can anyone please suggest what  file has to be imported in IMPORT WADL ?

  • December 10, 2013
  • Like
  • 0

I have to integrate CTI system with Salesforce. I have installed open CTI from following link.

http://wiki.developerforce.com/page/Open_CTI#Installing_The_Demo_Open_CTI_Adapter

 

Can anyone guide me How can I configure it with my CTI System? I have simple requirement. I have to open relative account page as a pop up when a call is reached at CTI System.Please help.

I'm developing hybrid app with offline functions; without network connection data should be read from local storage.

 

I believe SmartSync should do this, but does that store data so it will be available even after rebooting the device ?

 

When starting the application, it tries to connect SF but if network is not available then the error message will be shown. Can this error message be bypassed and continue to application itself, then load data from storage ? Later if modify/create records, in (or before) sync method network connection will be checked and either update local storage or SF.

 

Is this possible or out of question ?

  • October 17, 2013
  • Like
  • 0