• BenjaminB
  • NEWBIE
  • 50 Points
  • Member since 2013

  • Chatter
    Feed
  • 2
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 6
    Replies

Hi guys,

 

I'm looking for a way to lookup a user and then add that user as the primary contact for a contract. Right now I have the user pick the contact from a picklist and then I store the contact in a custom field. The problem is that I need that user to be placed in the Contact Roles object. Does anyone know how to do that?  Is it at all possible with Visual Flows?

 

Thanks for your help!

Hi guys,

 

I have an issue with an invalid url according to SFDC. I opened a topic on the programming here.

 

The symptom is that SalesForce throws the Invalid Page Redirection error:

 

Invalid Page Redirection
The page you attempted to access has been blocked due to a redirection to an outside website or an improperly coded link or button. Please contact your salesforce.com Administrator for assistance.

 

My question is whether I can find out what the invalid url was? I mean, I would like to look up in the debug what the final link was that broke the system.

 

Cheers!

Hi Guys,

 

Yet another question from my side. I'll quickly explain what I'm trying to do: I've created a visual flow in which employees go through a contract wizard. It creates a contract record with the information they filled in and then submits it for approval. I made it so the user has to do as few interactions as possible because we all know users can be stupid and need to have as few room as possible to forget things.

 

For all the contracts the process is finished when the wizard is done except for one contract type. For that type they need to upload a file. Since visual flow doesn't have that function I needed another way to achieve the upload.

 

What I did was to let the flow construct an url that when clicked showed them to the upload screen and also passed a return url so that they would be returned to a flow in which their submission would be submitted for approval. The url that is created in the flow looks like this:

/p/attach/NoteAttach?pid={!var_RecordID}&parentname={!ret_ContractNumber}&retURL=/flow/Simple_Approval_Tool?var_RecordID={!var_RecordID}

 And when clicked this url works perfectly. The problem is that people don't click the link, they forget and just click finish. So I had to set this url as finish location and thus came the following code. 

 

In principle it works so save your time scrutenizing the whole thing ;) The only part that doesn't work is the actual redirect to the "pp" page. I must confess though, that I do not get why the redirect works since in the VF page the reference is to {!OID} and in the controller we only have "getOID()". But it works for the "other" contracts and redirects them to the newly created (and submitted) record.

 

For the VisualForce page I have:

<apex:page Controller="ContractRequestFlowController" TabStyle="Account">
    <br/>
     <flow:interview name="Contract_Request_Wizard" interview="{!myflow}" finishlocation="{!OID}" />
</apex:page>

 And for the controller I have:

public class ContractRequestFlowController{
public Flow.Interview.Contract_Request_Wizard myFlow { get; set; }

public String getmyID() {
if (myFlow==null) return '';
else return myFlow.var_RecordID; //Retrieves var_RecordID from the flow. Important is that the var isnt private!
}

public String getRecordTypeID() {
if (myFlow==null) return '';
else return myFlow.var_ContractRecordTypeID;
}

public String getContractNumber() {
if (myFlow==null) return '';
else return myFlow.ret_ContractNumber;
}      

public String createUploadUrl() { //creates a string which is the upload url
return '/p/attach/NoteAttach?pid=' + getmyID() + '&retURL=/flow/Simple_Approval_Tool?var_RecordID=' + getmyID(); //works until I refer it to the Simple Approval Tool
}// As soon as '=/flow/Simple_Approval_Tool?var_RecordID' is added behind retURL= the system breaks.
    
public PageReference getOID(){
    PageReference p = new PageReference('/' + getmyID()); //This works like a charm!
    PageReference pp = new PageReference(createUploadUrl());//
    p.setRedirect(true);
    pp.setRedirect(true);
    if(getRecordTypeID() == '012400000005ZPM'){ //RecordTypeID of a specific type of agreement for which people need to upload a file.
   	return pp;}
    
    else{
        return p;}
}

}

 Again this works perfectly. It redirects when it needs to, it matches the record type ID perfectly. The problem lies in the fact that I cannot let it refer the retURL location to: 

/p/attach/NoteAttach?pid=' + getmyID() + '&retURL=/flow/Simple_Approval_Tool?var_RecordID=' + getmyID()

It does work If I refer it to:

/p/attach/NoteAttach?pid=' + getmyID() + '&retURL=' + getmyID()

 It fires:

Invalid Page Redirection
The page you attempted to access has been blocked due to a redirection to an outside website or an improperly coded link or button. Please contact your salesforce.com Administrator for assistance.

 

Any clue on how to fix this? Again, if I enter the link manually in the address bar it does work.

I was thinking I might redirect to a different VF page that would include an upload screen and then submit the record for approval, but I'm afraid I might run into the same issue there.

 

Any ideas would be much appreciated!

 

 

---edit---

Someone just pointed out that it might be possible to combine the fact that there is a newly created record (of the certain type) and the fact that a file was uploaded in a trigger which would then automatically submit the record for approval - thus eliminated the neccecity to set the redirect to a flow or apex that submits for approval. Any thoughts on this would also be appreciated.

Hi guys,

 

I'm new to SFDC and I'm trying to achieve some automation for my co-workers.

What I've done is build a visual workflow that guides my co-workers through a wizard in which they choose a contract, fill in the required fields and then automatically submits their request for approval. So far so good.

 

Now for the second stage:

After I've approved the request, I create a document and upload it to the record and send an email to the person that requested the contract, the account owner (AO).

 

Now the account owner needs to 1)click "send an email" 2)pick the template 3) add the recipient's email address 4)add the email address of a couple of co-workers (always the same) 4) attach the document 5) click send 6) change the record status to "sent to partner".

 

The thing is that a lot of the information is always the same and should therefore not have to be entered manually. People tend to forget to add the co-workers to the cc, attach the document and most of all: they forget to change the status.

 

So I'm looking for a way to make something that populates everything (template, cc, attachment) and then sends the email when the user clicks and then finally changes the record status.

 

I have a couple of years of programming experience, but not with Java and I simply do not get how it works in SFDC. I tried to copy/paste the code of a plugin into the developer console and then saving it, but it wouldn't let me. This was for the first part to submit a record for approval. When I uploaded it with the ANT it did work, so the code was fine. What I'm trying to say is that I do understand (java) code, but I have no clue how to implement it into SFDC. 

 

I would be forever thankful if someone would give me an idiot proof guide on how to enter the code I need.

 

Thank you!

Hi people,

 

I'm looking for a way to use the ID of the current flow in  a reference.

 

I'm building a flow for people to request contracts. The steps are basically this:

  1. First they choose which company the contract is for (or pass its ID via the url)
  2. They then have to choose which contract
  3. Provide data
  4. confirm and the contract then gets submitted for approval (Thank you so much raja-sfdc for the plug-in for that!)

The problem is that for one contract people need to upload a file to the record. The file upload doesn't work from inside Flow so I've made use of the retURL (which is a parameter in the upload screen url containing the location to return to).

Basically I'm providing a link to the upload page which then returns to the flow afterwards:

 

salesforce.com/p/attach/NoteAttach?pid={!var_RecordID} & parentname={!ret_ContractNumber}
 & retURL=/flow/Contract_Request_Wizard/ {!var_FlowID} ?var_RecordID= {!var_RecordID}

 

This works perfectly except that I have to provide the var_FlowID manually each time. Is there a way that the flow could actually pass its own ID to the var_FlowID?

 

I hope I explained my problem clearly enough and that somebody is able to help!

 

Thanks!

 

Hi guys,

 

I'm struggling with developing a plug-in for Visual Workflow to make it possible to submit a record for approval.

I want the plug-in to work with a mandatory RecordID and optional comment. Right now I've got the following code:

public class FlowApprovalSubmit{
// This method describes this plugin, as well as its inputs and outputs to the Cloud Designer
// NOTE: Implementing this method is what makes this class appear in the designer
global Process.PluginDescribeResult describe() {
    // Set up plugin metadata
    Process.PluginDescribeResult result = new Process.PluginDescribeResult();
    result.description = 'The FlowApprovalSubmit Flow Plug-in submits a requested record for approval';
    result.tag = 'Approval Handling';
 
    // create a list that stores both mandatory and optional *input* parameters from a Flow
    // NOTE: Only primitive types (STRING, NUMBER, etc) are supported at this time.
	// Collections are not currently supported
    result.inputParameters = new List<Process.PluginDescribeResult.InputParameter>{
        // Record ID (mandatory)
        new Process.PluginDescribeResult.InputParameter('RecordID',
                Process.PluginDescribeResult.ParameterType.STRING, true),
        // Comments (optional)
        new Process.PluginDescribeResult.InputParameter('ApprovalComments',
                Process.PluginDescribeResult.ParameterType.STRING, false),
    };
 
    // Create a list that stores *output* parameters sent *to* your flow.
    result.outputParameters = new List<Process.PluginDescribeResult.OutputParameter>{
        // Account ID of the converted lead
        new Process.PluginDescribeResult.OutputParameter('getComments',
                Process.PluginDescribeResult.ParameterType.STRING),
        //...
    };
 
    return result;
};

global Process.PluginResult invoke(Process.PluginRequest request) {
    String RecordID = (String) request.inputParameters.get('RecordID');
    String ApprovalComments = (String) request.inputParamaters.get('ApprovalComments')
	
		Approval.ProcessSubmitRequest req1 = new Approval.ProcessSubmitRequest();
			req1.setComments(ApprovalComments);
			req1.setObjectId(RecordID);
		Approval.ProcessResult result = Approval.process(req1);
	
    return new Process.PluginResult(result);
}

}

 

 The problem that it returns is on line 20 where it doesn't expect the "}"

 

Could someone please tell my why and how I can solve it? Also, I would be very thankful if someone reviewed the code and gave me pointers.

 

Thank you so much!

Hi guys,

 

I'm looking for a way to lookup a user and then add that user as the primary contact for a contract. Right now I have the user pick the contact from a picklist and then I store the contact in a custom field. The problem is that I need that user to be placed in the Contact Roles object. Does anyone know how to do that?  Is it at all possible with Visual Flows?

 

Thanks for your help!

Hi Guys,

 

Yet another question from my side. I'll quickly explain what I'm trying to do: I've created a visual flow in which employees go through a contract wizard. It creates a contract record with the information they filled in and then submits it for approval. I made it so the user has to do as few interactions as possible because we all know users can be stupid and need to have as few room as possible to forget things.

 

For all the contracts the process is finished when the wizard is done except for one contract type. For that type they need to upload a file. Since visual flow doesn't have that function I needed another way to achieve the upload.

 

What I did was to let the flow construct an url that when clicked showed them to the upload screen and also passed a return url so that they would be returned to a flow in which their submission would be submitted for approval. The url that is created in the flow looks like this:

/p/attach/NoteAttach?pid={!var_RecordID}&parentname={!ret_ContractNumber}&retURL=/flow/Simple_Approval_Tool?var_RecordID={!var_RecordID}

 And when clicked this url works perfectly. The problem is that people don't click the link, they forget and just click finish. So I had to set this url as finish location and thus came the following code. 

 

In principle it works so save your time scrutenizing the whole thing ;) The only part that doesn't work is the actual redirect to the "pp" page. I must confess though, that I do not get why the redirect works since in the VF page the reference is to {!OID} and in the controller we only have "getOID()". But it works for the "other" contracts and redirects them to the newly created (and submitted) record.

 

For the VisualForce page I have:

<apex:page Controller="ContractRequestFlowController" TabStyle="Account">
    <br/>
     <flow:interview name="Contract_Request_Wizard" interview="{!myflow}" finishlocation="{!OID}" />
</apex:page>

 And for the controller I have:

public class ContractRequestFlowController{
public Flow.Interview.Contract_Request_Wizard myFlow { get; set; }

public String getmyID() {
if (myFlow==null) return '';
else return myFlow.var_RecordID; //Retrieves var_RecordID from the flow. Important is that the var isnt private!
}

public String getRecordTypeID() {
if (myFlow==null) return '';
else return myFlow.var_ContractRecordTypeID;
}

public String getContractNumber() {
if (myFlow==null) return '';
else return myFlow.ret_ContractNumber;
}      

public String createUploadUrl() { //creates a string which is the upload url
return '/p/attach/NoteAttach?pid=' + getmyID() + '&retURL=/flow/Simple_Approval_Tool?var_RecordID=' + getmyID(); //works until I refer it to the Simple Approval Tool
}// As soon as '=/flow/Simple_Approval_Tool?var_RecordID' is added behind retURL= the system breaks.
    
public PageReference getOID(){
    PageReference p = new PageReference('/' + getmyID()); //This works like a charm!
    PageReference pp = new PageReference(createUploadUrl());//
    p.setRedirect(true);
    pp.setRedirect(true);
    if(getRecordTypeID() == '012400000005ZPM'){ //RecordTypeID of a specific type of agreement for which people need to upload a file.
   	return pp;}
    
    else{
        return p;}
}

}

 Again this works perfectly. It redirects when it needs to, it matches the record type ID perfectly. The problem lies in the fact that I cannot let it refer the retURL location to: 

/p/attach/NoteAttach?pid=' + getmyID() + '&retURL=/flow/Simple_Approval_Tool?var_RecordID=' + getmyID()

It does work If I refer it to:

/p/attach/NoteAttach?pid=' + getmyID() + '&retURL=' + getmyID()

 It fires:

Invalid Page Redirection
The page you attempted to access has been blocked due to a redirection to an outside website or an improperly coded link or button. Please contact your salesforce.com Administrator for assistance.

 

Any clue on how to fix this? Again, if I enter the link manually in the address bar it does work.

I was thinking I might redirect to a different VF page that would include an upload screen and then submit the record for approval, but I'm afraid I might run into the same issue there.

 

Any ideas would be much appreciated!

 

 

---edit---

Someone just pointed out that it might be possible to combine the fact that there is a newly created record (of the certain type) and the fact that a file was uploaded in a trigger which would then automatically submit the record for approval - thus eliminated the neccecity to set the redirect to a flow or apex that submits for approval. Any thoughts on this would also be appreciated.

Hi guys,

 

I'm new to SFDC and I'm trying to achieve some automation for my co-workers.

What I've done is build a visual workflow that guides my co-workers through a wizard in which they choose a contract, fill in the required fields and then automatically submits their request for approval. So far so good.

 

Now for the second stage:

After I've approved the request, I create a document and upload it to the record and send an email to the person that requested the contract, the account owner (AO).

 

Now the account owner needs to 1)click "send an email" 2)pick the template 3) add the recipient's email address 4)add the email address of a couple of co-workers (always the same) 4) attach the document 5) click send 6) change the record status to "sent to partner".

 

The thing is that a lot of the information is always the same and should therefore not have to be entered manually. People tend to forget to add the co-workers to the cc, attach the document and most of all: they forget to change the status.

 

So I'm looking for a way to make something that populates everything (template, cc, attachment) and then sends the email when the user clicks and then finally changes the record status.

 

I have a couple of years of programming experience, but not with Java and I simply do not get how it works in SFDC. I tried to copy/paste the code of a plugin into the developer console and then saving it, but it wouldn't let me. This was for the first part to submit a record for approval. When I uploaded it with the ANT it did work, so the code was fine. What I'm trying to say is that I do understand (java) code, but I have no clue how to implement it into SFDC. 

 

I would be forever thankful if someone would give me an idiot proof guide on how to enter the code I need.

 

Thank you!

Hi people,

 

I'm looking for a way to use the ID of the current flow in  a reference.

 

I'm building a flow for people to request contracts. The steps are basically this:

  1. First they choose which company the contract is for (or pass its ID via the url)
  2. They then have to choose which contract
  3. Provide data
  4. confirm and the contract then gets submitted for approval (Thank you so much raja-sfdc for the plug-in for that!)

The problem is that for one contract people need to upload a file to the record. The file upload doesn't work from inside Flow so I've made use of the retURL (which is a parameter in the upload screen url containing the location to return to).

Basically I'm providing a link to the upload page which then returns to the flow afterwards:

 

salesforce.com/p/attach/NoteAttach?pid={!var_RecordID} & parentname={!ret_ContractNumber}
 & retURL=/flow/Contract_Request_Wizard/ {!var_FlowID} ?var_RecordID= {!var_RecordID}

 

This works perfectly except that I have to provide the var_FlowID manually each time. Is there a way that the flow could actually pass its own ID to the var_FlowID?

 

I hope I explained my problem clearly enough and that somebody is able to help!

 

Thanks!

 

Hi guys,

 

I'm struggling with developing a plug-in for Visual Workflow to make it possible to submit a record for approval.

I want the plug-in to work with a mandatory RecordID and optional comment. Right now I've got the following code:

public class FlowApprovalSubmit{
// This method describes this plugin, as well as its inputs and outputs to the Cloud Designer
// NOTE: Implementing this method is what makes this class appear in the designer
global Process.PluginDescribeResult describe() {
    // Set up plugin metadata
    Process.PluginDescribeResult result = new Process.PluginDescribeResult();
    result.description = 'The FlowApprovalSubmit Flow Plug-in submits a requested record for approval';
    result.tag = 'Approval Handling';
 
    // create a list that stores both mandatory and optional *input* parameters from a Flow
    // NOTE: Only primitive types (STRING, NUMBER, etc) are supported at this time.
	// Collections are not currently supported
    result.inputParameters = new List<Process.PluginDescribeResult.InputParameter>{
        // Record ID (mandatory)
        new Process.PluginDescribeResult.InputParameter('RecordID',
                Process.PluginDescribeResult.ParameterType.STRING, true),
        // Comments (optional)
        new Process.PluginDescribeResult.InputParameter('ApprovalComments',
                Process.PluginDescribeResult.ParameterType.STRING, false),
    };
 
    // Create a list that stores *output* parameters sent *to* your flow.
    result.outputParameters = new List<Process.PluginDescribeResult.OutputParameter>{
        // Account ID of the converted lead
        new Process.PluginDescribeResult.OutputParameter('getComments',
                Process.PluginDescribeResult.ParameterType.STRING),
        //...
    };
 
    return result;
};

global Process.PluginResult invoke(Process.PluginRequest request) {
    String RecordID = (String) request.inputParameters.get('RecordID');
    String ApprovalComments = (String) request.inputParamaters.get('ApprovalComments')
	
		Approval.ProcessSubmitRequest req1 = new Approval.ProcessSubmitRequest();
			req1.setComments(ApprovalComments);
			req1.setObjectId(RecordID);
		Approval.ProcessResult result = Approval.process(req1);
	
    return new Process.PluginResult(result);
}

}

 

 The problem that it returns is on line 20 where it doesn't expect the "}"

 

Could someone please tell my why and how I can solve it? Also, I would be very thankful if someone reviewed the code and gave me pointers.

 

Thank you so much!