• pinki
  • NEWBIE
  • 0 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 1
    Replies
Hi, I have the requirement like this. Say I have a Visualforce page which has '<apex:page> This is a new page </apex:page>'. Then I want an audio player on that page which will play this exact statement "This is a new page." Is this possible to be done in Apex? Or through Javascript on Apex? If anyone has done this or know about how it can be implemented, please share the relevant steps and code. 
  • January 19, 2017
  • Like
  • 0
Hi, I am new to ToolingAPI. I have written code to create a VF Page from a class using Tooling API. Now what I require is to create Visualforce Pages based on the user's selection of picklist values. For example, a picklist field VFPageValues contains 'A','B','C'. Now, when user selects picklist value A, VF page created will be 'TestPageA', if user selects picklist value B, VF page created will be 'TestPageB'.

I have taken the user-selected picklist value in a string say,mcc. How can I incorporate this in the req.setBody() parameter?
Currently I have:

req.setBody('{"Name" : "TestPage","Markup" : "<apex:page>hello</apex:page>","ControllerType" : "0","MasterLabel":"TestPageFromRest","ApiVersion":"29.0"}');

within the public static void createPage() {} method which runs when user selects a picklist value. 

But this creates just page "TestPage" and does not append the user-selected picklist value. What is the proper syntax to add the mcc value to this req.setBody parameter?
  • January 18, 2017
  • Like
  • 0
How can we update a visualforce page from a class through Tooling API? I am using the below code which creates a Visualforce page called 'TestPageFromRest'. If I want to conditionally update the page next time, how can I do it? Please share the code if someone knows.

public class ToolingNewPage{

   
private static String baseUrl = URL.getSalesforceBaseUrl().toExternalForm() 
    + '/services/data/v28.0/tooling/';
public static void createPage() {
    
    String salesforceHost = System.Url.getSalesforceBaseURL().toExternalForm();

String url =  salesforceHost + '/services/data/v29.0/sobjects/ApexPage';

HttpRequest req = new HttpRequest();

req.setMethod('POST');
req.setEndpoint(url);
req.setHeader('Content-type', 'application/json');
req.setHeader('Authorization', 'Bearer ' + UserInfo.getSessionId());
//for controllerType = >0 -- no controller
req.setBody('{"Name" : "TestPageFromRest","Markup" : "<apex:page>hello</apex:page>","ControllerType" : "0","MasterLabel":"TestPageFromRest","ApiVersion":"29.0"}');

//for controllerType => 1 -- Standard controller + extensions        
//req.setBody('{"Name" : "TestPageFromRestCase","Markup" : "<apex:page standardController=\'case\' extensions=\'displaycase\'>hello</apex:page>","ControllerType" : "1","MasterLabel":"TestPageFromRestCase","ApiVersion":"29.0"}');

//for controllerType => 3 --custom Controller
//req.setBody('{"Name" : "TestPageFromRestCase1","Markup" : "<apex:page controller=\'displaycase\'>hello</apex:page>","ControllerType" : "3","MasterLabel":"TestPageFromRestCase1","ApiVersion":"29.0"}');            
Http http = new Http();

HTTPResponse res = http.send(req);
System.debug(res.getBody());
}}

 
  • January 17, 2017
  • Like
  • 0

I have a custom object, say VF_Page_Update__c which has say, a picklist field called VF_Page_Name. This field will contain the names of some VF Pages say A,B,C,D. I also have another text field in this object called Update__c.
What I require is, say I write 'Test' in the Update__c field and choose A as the VF page Name. Then a new field will be created in the A Visualforce Page with 'Test' as the data.
Is this possible? Do I require the use of any API? If anyone is able to do this, can you please share the code for this?
  • January 17, 2017
  • Like
  • 0
Hi, I have the requirement like this. Say I have a Visualforce page which has '<apex:page> This is a new page </apex:page>'. Then I want an audio player on that page which will play this exact statement "This is a new page." Is this possible to be done in Apex? Or through Javascript on Apex? If anyone has done this or know about how it can be implemented, please share the relevant steps and code. 
  • January 19, 2017
  • Like
  • 0