function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
alliswellalliswell 

Java Code to salesforce

Hi All,

 

I have been looking for devising a solution but I keep on heading a roadblock. Ryan from Salesforce and sfdcfox helped me a lot.  

 

Say a requirement is user shall be able to browse for a file, select it, and then store it's name and path in salesforce custom fields.

Fetching a file name and storing it in Salesforce is absolutely feasible. But the main issue I have been facing from day one is to actually fetch a path and store it in salesforce custom fields.

 

here's a very simple java code that can do it: But how can I do the same in salesforce?

 

import java.io.*;

import javax.swing.*;

 

 

public class FilePath1 {

        public static void main(String[] args) {

                try{

                  JFileChooser fc = new JFileChooser();

                  fc.showOpenDialog(null);

                  File file = fc.getSelectedFile();

                  String filename = file.getName();

                  System.out.println("File Name " + filename);

                  System.out.println("Path : " + file.getPath());

                }

                        catch(Exception e){

                              // if any error occurs

                              e.printStackTrace();

                        }

                  }

                  }

Puneet SardanaPuneet Sardana
A simple solution to this is using javascript.. Identify the component using its id,retrieve its value and then make a call to the apex method passing the retrieved value as parameter.
alliswellalliswell

Puneet I am afraid I don't understand. Could you please elaborate?

 

Thanks!!