• Suraj Singh
  • NEWBIE
  • 60 Points
  • Member since 2015
  • Developer
  • Aifly Technology Solutions Pvt. Ltd.


  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 14
    Replies
I have only been working in Visualforce for a week, so forgive me if this is a stupid question.

I have a 'Custom Object' called 'Request__c'. I also have a custom object called 'Time_Entry__c' that is managed through a Visualforce page and is functionally a child of 'Request__c' and is displayed on the 'Request__c' form in Salesforce. I have some code where I am trying to pass the object id of the 'Request__c' object to the Apex method so that its value is included when I create a new instance (row) of the 'Time_Entry__c' object. However, the code that I have developed is not working. Please see the relevent code below. I would appreciate any help that I can get. Thank you so much.

VISUALFORCE code

<apex:page standardController="Request__c" extensions="TrController">
    <!--Because we will be defining 'Input' fields, we must wrap our code in a 'Form' block. -->
    <apex:form >
        <apex:pageBlock title="CDCR - Salesforce Time Reporting for Requests">
            <apex:pageBlockButtons >
                <!-- The following Button is defined in a more complicated fashion so that a parameter can be passed. -->
                <apex:commandButton >
                    <a href="javascript: CurrRequest('{!Request__c.Id}');" >New</a>               
                </apex:commandButton>
                <apex:commandButton value="Save" action="{!save}"/>
            </apex:pageBlockButtons>

...

       <apex:actionFunction action="{!add}" name="CurrRequest" reRender="">
            <apex:param name="EntryID" value="" assignTo="{!ReqID}"/>
        </apex:actionFunction>

    </apex:form>
</apex:page>

APEX Controller

public with sharing class TrController
{
    public List<Time_Entry__c> TimeEntries {get;set;}
    public string reqRslt {get;set;}
    public string showMessage {get;set;}
    //Used to get a hold of the entry record that is selected for deletion.
    public string SelectedEntryID {get;set;}
    public string ReqID {get;set;}
    public TrController(ApexPages.StandardController controller)
    {
        LoadData();
     }

...

    private void LoadData()
    {
        //Load the related time entry records from the database.
        //TimeEntries = [select id, Activity__c, Date_Worked__c, Hours_Worked__c, Minutes_Worked__c, Work_Description__c from Time_Entry__c WHERE name=:profileName order by ID DESC];

        TimeEntries = [select id, Activity__c, Date_Worked__c, Hours_Worked__c, Minutes_Worked__c, Work_Description__c, Related_Object__c from Time_Entry__c order by ID DESC];
    }
...

    public void add()
    {  
        //The following line will obetain the request id (ReqId) that is passed from the VisualForce page
        string RequestID = ReqId;
        //Build the default values to the new time entry record.
        Time_Entry__c entry = new Time_Entry__c(Activity__c='Research', Date_Worked__c=System.today(), Hours_Worked__c=' 0', Minutes_Worked__c='00', Related_Object__c=RequestID);
        //Insert the new default time entry row into the Salesforce database.
        Insert entry;
        //Call the method to reload the Visualforce list.
        LoadData();
    }


   
My issue is that, we have a converted lead that was already synced in the pardo, After the we have created a custom Object, related to the lead, and when we put the Converted Lead Id in out Newly custom Object then, that record was not appearing in the Pardot?
Any Guess why this is happening?
Hi All,
Whenever we make a request to Microsoft one drive, it will always throws the error
{ "error": { "code": "BadRequest", "message": "The MIME type 'text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2' requires a '/' character between type and subtype, such as 'text/plain'.", "innerError": { "request-id": "8b4202bd-d0db-4c2f-9c0a-9186aae3f6ee", "date": "2017-05-01T17:20:30" } } }
Now the strange thing is that,
When we made a request to create a folder or upload a file on one-Drive, if will done successfully but the response is still same, Since response was not correct, so we are unable to know is folder created or not?, what was the id of created folder?
Here is the code that we are using to get USER.
    Http h = new Http();
	HttpRequest req = new HttpRequest();	
	req.setMethod('GET');
	req.setHeader('Authorization', 'Bearer ' + accessToken);
	req.setEndpoint('https://graph.microsoft.com/v1.0/users');
	HttpResponse res;
	try {
		res = h.send(req);
		System.debug('HTTP Response Code: ' + res.getStatusCode());
		System.debug('Response Body: ' + res.getBody());
	} catch (Exception e) {
		System.debug('Callout Error:' + e.getMessage());            
	}
Thank you.
 
Response code: 400
Error,  { "error": { "code": "BadRequest", "message": "The MIME type 'text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2' requires a '/' character between type and subtype, such as 'text/plain'.", "innerError": { "request-id": "822a994e-6ef7-4c4c-bd27-5b96186165f0", "date": "2017-04-13T13:44:15" } } }

        HttpRequest req = new HttpRequest();
        req.setMethod('GET');
        req.setHeader('Content-Type', 'application/json');
        req.setHeader('Authorization', 'Bearer '+ accessToken);
        req.setEndpoint('https://graph.microsoft.com/v1.0/me/drive/root');      
        HttpResponse res = h.send(req);
When we create a new email or reply to an email from a case, after clicking on send, we receive this error - https://prnt.sc/p85v24. Asked for customer support assistance and they advised that it might be an APEX code issue and to come ask here.

I appreciate the help
Hi All,
Whenever we make a request to Microsoft one drive, it will always throws the error
{ "error": { "code": "BadRequest", "message": "The MIME type 'text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2' requires a '/' character between type and subtype, such as 'text/plain'.", "innerError": { "request-id": "8b4202bd-d0db-4c2f-9c0a-9186aae3f6ee", "date": "2017-05-01T17:20:30" } } }
Now the strange thing is that,
When we made a request to create a folder or upload a file on one-Drive, if will done successfully but the response is still same, Since response was not correct, so we are unable to know is folder created or not?, what was the id of created folder?
Here is the code that we are using to get USER.
    Http h = new Http();
	HttpRequest req = new HttpRequest();	
	req.setMethod('GET');
	req.setHeader('Authorization', 'Bearer ' + accessToken);
	req.setEndpoint('https://graph.microsoft.com/v1.0/users');
	HttpResponse res;
	try {
		res = h.send(req);
		System.debug('HTTP Response Code: ' + res.getStatusCode());
		System.debug('Response Body: ' + res.getBody());
	} catch (Exception e) {
		System.debug('Callout Error:' + e.getMessage());            
	}
Thank you.
 
Response code: 400
Error,  { "error": { "code": "BadRequest", "message": "The MIME type 'text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2' requires a '/' character between type and subtype, such as 'text/plain'.", "innerError": { "request-id": "822a994e-6ef7-4c4c-bd27-5b96186165f0", "date": "2017-04-13T13:44:15" } } }

        HttpRequest req = new HttpRequest();
        req.setMethod('GET');
        req.setHeader('Content-Type', 'application/json');
        req.setHeader('Authorization', 'Bearer '+ accessToken);
        req.setEndpoint('https://graph.microsoft.com/v1.0/me/drive/root');      
        HttpResponse res = h.send(req);
I have only been working in Visualforce for a week, so forgive me if this is a stupid question.

I have a 'Custom Object' called 'Request__c'. I also have a custom object called 'Time_Entry__c' that is managed through a Visualforce page and is functionally a child of 'Request__c' and is displayed on the 'Request__c' form in Salesforce. I have some code where I am trying to pass the object id of the 'Request__c' object to the Apex method so that its value is included when I create a new instance (row) of the 'Time_Entry__c' object. However, the code that I have developed is not working. Please see the relevent code below. I would appreciate any help that I can get. Thank you so much.

VISUALFORCE code

<apex:page standardController="Request__c" extensions="TrController">
    <!--Because we will be defining 'Input' fields, we must wrap our code in a 'Form' block. -->
    <apex:form >
        <apex:pageBlock title="CDCR - Salesforce Time Reporting for Requests">
            <apex:pageBlockButtons >
                <!-- The following Button is defined in a more complicated fashion so that a parameter can be passed. -->
                <apex:commandButton >
                    <a href="javascript: CurrRequest('{!Request__c.Id}');" >New</a>               
                </apex:commandButton>
                <apex:commandButton value="Save" action="{!save}"/>
            </apex:pageBlockButtons>

...

       <apex:actionFunction action="{!add}" name="CurrRequest" reRender="">
            <apex:param name="EntryID" value="" assignTo="{!ReqID}"/>
        </apex:actionFunction>

    </apex:form>
</apex:page>

APEX Controller

public with sharing class TrController
{
    public List<Time_Entry__c> TimeEntries {get;set;}
    public string reqRslt {get;set;}
    public string showMessage {get;set;}
    //Used to get a hold of the entry record that is selected for deletion.
    public string SelectedEntryID {get;set;}
    public string ReqID {get;set;}
    public TrController(ApexPages.StandardController controller)
    {
        LoadData();
     }

...

    private void LoadData()
    {
        //Load the related time entry records from the database.
        //TimeEntries = [select id, Activity__c, Date_Worked__c, Hours_Worked__c, Minutes_Worked__c, Work_Description__c from Time_Entry__c WHERE name=:profileName order by ID DESC];

        TimeEntries = [select id, Activity__c, Date_Worked__c, Hours_Worked__c, Minutes_Worked__c, Work_Description__c, Related_Object__c from Time_Entry__c order by ID DESC];
    }
...

    public void add()
    {  
        //The following line will obetain the request id (ReqId) that is passed from the VisualForce page
        string RequestID = ReqId;
        //Build the default values to the new time entry record.
        Time_Entry__c entry = new Time_Entry__c(Activity__c='Research', Date_Worked__c=System.today(), Hours_Worked__c=' 0', Minutes_Worked__c='00', Related_Object__c=RequestID);
        //Insert the new default time entry row into the Salesforce database.
        Insert entry;
        //Call the method to reload the Visualforce list.
        LoadData();
    }


   
Hi All,

I have created a custom object which has a Master detail relationship with Standard Salesforce Event.I am unable to add the custom object as the related list to the Standard Event object.Please let me know the procedure.

Thanks & Regards,
Harsha BR

Thanks & Regards,
Harsha BR
here I only struggle to get the normal apex date value like in mm/dd/yyyy format. please help me to get this... I here try to provide a ownerid update for the tasks. it's specified by the duedate in the my datepicker. and that search and update function i done by remote actions respectively. my code as followingly,
controller:
//Remote function using updated the owner of the task
public class TaskOwnerUpdate {
    
    public String dueDate { get; set; }
    public Set<Id> selectedTaskIdSet {get; set;}
    String ownerIdValue {get; set;}
    String selectedColumnValue {get; set;}
    public static List<Task> taskList { get; set;}
    public TaskOwnerUpdate() { } // empty constructor
    public List<Task>selectedtaskList {get; set;}
    
    public Task getOwnerIdTask() {
    
        return [SELECT  OwnerId FROM TASK LIMIT 1];
    }
    
    @RemoteAction
    public static List<Task> getTask (String dueDate) {
    
        system.debug('dueDate value is------>'+dueDate);
        List<String> stList = dueDate.split('"');
        system.debug('stList value---->'+stList);
        List<String>s1 = stList[0].split(',');
        system.debug('stList[0] value is---->'+stList[0]);
        system.debug('stList[1] value is---->'+stList[1]);
        List<String> splitList = stList[1].split('/');
        system.debug('splitList value is---->'+splitList);
        String dueDate1 = splitList[2]+'-'+splitList[0]+'-'+splitList[1]; 
        taskList = [SELECT Id, Subject, Priority, Status, ActivityDate, Owner.Name, OwnerId
                   FROM Task WHERE ActivityDate >= :Date.valueOf(dueDate1)];
        system.debug('taskList- value is------>'+taskList);
        return taskList;        
    
    }
    
    @RemoteAction 
    public static List<Task> updateTask(String ownerIdValue, String selectedColumnValue ) {
    
        system.debug('OwnerId value is----->'+ownerIdValue);
        system.debug('selectedColumnValue value is---->'+selectedColumnValue);
        
        List<Task> updatedTaskList = new List<Task>();


        Set<Id> idSet = new Set<Id>();
        List<String> deserializeStringList = (List<String>)System.JSON.deserialize(selectedColumnValue, List<String>.class);
        
        system.debug('deserializeStringList value>>>>'+deserializeStringList);

        for (String strRecord : deserializeStringList) {
        
            Task taskRecord = new Task();
            taskRecord.Id = Id.valueOf(strRecord);
            taskRecord.OwnerId = Id.valueOf(ownerIdValue);
            updatedTaskList.add(taskRecord);
        } 
              
        if (updatedTaskList.size() > 0) {
            Update updatedTaskList;
        }
         return updatedTaskList;
         
    }
     
}

page:
<apex:page controller="TaskOwnerUpdate">
    <apex:form>
    <apex:includeScript value="https://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"/>
    <apex:includeScript value="https://ajax.microsoft.com/ajax/jquery.templates/beta1/jquery.tmpl.min.js"/>

    <apex:sectionHeader title="Task Ownership Update"/>

    <apex:pageBlock title="Tasks">
 <!---- Section to draw search field for account-------> 
        <apex:pageBlockSection title="Search Tasks" columns="2">
            <apex:pageBlockSectionItem >
                <apex:inputText value="{!dueDate}" size="10" id="demo" onfocus="DatePicker.pickDate(false, this , false)">dueDate</apex:inputText>
                <apex:inputField value="{!OwnerIdTask.OwnerId}" id="owner"></apex:inputField>
            </apex:pageBlockSectionItem>               
        </apex:pageBlockSection>
        
        <apex:pageBlockSection >
                <button onclick="getTask();return false;">Get Task</button>            
                <button id = "button">Update</button>     
        </apex:pageBlockSection>

        <apex:actionFunction name="callaction" oncomplete="getTask()" reRender="output"/>
    
     <!-- result section for showing matching accounts ------->
        <apex:outputPanel id="output">
            <apex:pageBlockSection title="Matching Tasks !" columns="1">
            <!-- 
            Created Empty table using the CSS styles of visualforce pageBlockTable 
            This gives same look and feel ------>
            
                <table cellspacing="0" cellpadding="0" border="0" id="searchResults" class="list ">
                    <colgroup span="2"></colgroup>
                    <thead class="rich-table-thead">
                        <tr class="headerRow ">
                            <th colspan="1" scope="col" class="headerRow">Select</th> 
                            <!--<th colspan="1" scope="col" class="headerRow">Id</th>---->
                            <th colspan="1" scope="col" class="headerRow">Subject</th>
                            <th colspan="1" scope="col" class="headerRow">Priority</th>
                            <th colspan="1" scope="col" class="headerRow">Status</th>
                            <th colspan="1" scope="col" class="headerRow">ActivityDate</th>
                            <th colspan="1" scope="col" class="headerRow">OwnerName</th>
                        </tr>
                    </thead>
                <!-- table body left empty for populating via row template using jquery-------> 
                    <tbody />
                </table>
            </apex:pageBlockSection>
        </apex:outputPanel>  
        
    <script id="resultTableRowTemplate" type="text/x-jquery-tmpl">
        <tr onfocus="if (window.hiOn){hiOn(this);}" onblur="if (window.hiOff){hiOff(this);}" onmouseout="if (window.hiOff){hiOff(this);} " onmouseover="if (window.hiOn){hiOn(this);} " class="dataRow even  first">
            <td class="datacel">${Select}<input type = "checkbox" id="${Id}"/></td>
            <!---<td class="Idvalue">${Id}</td>------>
            <td class="datacell">${Subject}</td>
            <td class="dataCell">${Priority}</td>
            <td class="dataCell">${Status}</td>
            <td class="datecell">${ActivityDate}</td>
            <td class="datacell">${Owner.Name}</td>      
        </tr>
    </script>
    
  </apex:pageBlock> 
                 
    <script type="text/javascript">
        // if you are inside some component
        // use jquery nonConflict
        // var t$ = jQuery.noConflict();
        console.log("check call correct");
      
        function getTask() {
        
            var dueDate = $('[id$=":demo"]').val();//$('#demo').val();
            console.log("check data",dueDate);
            // clear previous results, if any
            $("#searchResults tbody").html('');
            
            // The Spring-11 gift from force.com. Javascript remoting fires here
            // Please note "abhinav" if my org wide namespace prefix
            // testremotingcontroller is the Apex controller
            // searchAccounts is Apex Controller method demarcated with @RemoteAction annotation.
            // DEPRECATED -     abhinav.testremotingcontroller.searchAccounts( accountName, ...) 
            // NEW - summer'12 approach for calling'
            
            dueDate = JSON.stringify(dueDate);
            Visualforce.remoting.Manager.invokeAction('{!$RemoteAction.TaskOwnerUpdate.getTask}',
                           dueDate, function(result, event){  
                           console.log("due date",dueDate);          
                if (event.status && event.result) {  
                  $.each(event.result, function () {                
                     // for each result, apply it to template and append generated markup
                     // to the results table body.
                     $("#resultTableRowTemplate" ).tmpl(this).appendTo( "#searchResults tbody" );
                  }
                 );            
                } else {
                   alert(event.message);
                }
            }, {escape:true});
        }
    </script>

    <script type="text/javascript">
        console.log("check update correct");
        
        $(function () {
          
          $('.datacel').click(function() {
            var allData = $(this).parent().parent().first().text();
            console.log("allData value is>>>>",allData);
            //alert(allData);
          });
          
          $('input:not(#button)').click(function () {
            t = $(this).attr('id');
        
            text = $('.time' + t).text();
            //alert(text);
          });
        
          $('#button').click(function (e) {
            e.preventDefault();
            var trs = $('table tr');
            var values = trs.first().find('td');
           // var idr = $('#Idvalue').val();
           // console.log("idr value",idr);
            var values1 = $('table tr td :checkbox:checked').map(function () {
             
             console.log('\nId::::',$(this).attr('id'));
             return $(this).attr('id');
             
             /*return $(this).closest('tr').find('td').text() + "=="
             + values.eq($(this).parent().index()).text();
             console.log("id val",$(this).parent().find('td').eq(1).text());
             return $(this).closest('td').find('td').eq(1).text()+
             values.eq($(this).parent().intex()).text();*/
                
            }).get(); 
                
            console.log("values1",values1);
            getUpdate(values1);
            console.log("after passing vales1", values1);
            console.log("values1",values1);
            return values1;

            });
        
            //alert(values1);
            //console.log("values1",values1);
            //return values1;           
            //getUpdate(values1);
        
          });    
    
        function getUpdate(values1) { 
        
            var taskRecord = JSON.stringify(values1);
            console.log("data type taskRecord",typeof(taskRecord));
            console.log("task record value is>>>",taskRecord);
            var ownerIdValue = $('[id$="owner_lkid"]').val();
            console.log("data type ownerIdValue",typeof(ownerIdValue));
            //var ownerIdValue = document.getElementById('{!$Component.owner}').value;
            console.log("ownerId value is >>>>",ownerIdValue);
            console.log("values1 >>>>",values1);
            Visualforce.remoting.Manager.invokeAction('{!$RemoteAction.TaskOwnerUpdate.updateTask}',
                       ownerIdValue, taskRecord, function(result, event){  
                              
            if (event.status) {  
            
                     callaction();   
            } else {
               
            }
            }, {escape:true});            
         }
    </script> 

    </apex:form>
</apex:page>

For any response appreciated!!!! 
Hello,
I have a scenario, where, I will connect with a FTP server from sfdc and read a csv file, the update/insert a salesforce object with csv data.
This action will perforn hourly basis. I can not use Dataloader as for that I have to install dataloader in to FTP server (I dont have permission to do so).

Can any one help me withe workarround.

I do not know, if I can use external object or odata connection for this or if there are any connector with will be installed in the org and can be scheduled

Thanks in advance
Ashish

Hi All,

 

I have my salesfoce instance integrated with a third party application. This TPA sends some lead records to Salesforce and then it is created in salesforce. Now when they sent a record they get the following error.

 

System.Exception: user does not have access to use approval assignment email template

 

Does anyone know how this error occurs and how to solve it?

 

Regards

Rony

How can I add leads in Account object related list in page layout?

Hi,

 

Is there any way to do multiple call outs in a single txn where there are DML operations?

Is it possible to "create" a Site instance to use in test methods? I have a controller that does slightly different things depending on which Site is accessing it, but Site.getName() is always null in my test methods. It doesn't seem to be possible to do a Site newSite = new Site(), so what is the correct way to do this?

 

Thanks,

Tom