how to avoid to users to updating the file extension?

  • 1
  • Question
  • Updated 2 years ago
  • Answered
I am very new to skuid.
I have following requirement. If possible anyone could help me to do this. I need  snippet code and how to render that actually.

1.Run Snippet:   The snippet should do the following:
   a)Compare the old file extension in the file name (i.e. the characters that come after the last period (.) in the file name, if the filename has any periods in it) with the file extension of the new file name.
   b)If they are not equal, return false; which will trigger the OnError action step, else return true;
2.Add an OnError action to the Run Snippet step:
   a)Show Popup. The popup should have the following text "If you change a file name extension, the file might become unstable. Are you sure you want to change it?" followed by two buttons "Yes, Change It" and "No, Revert Back".
      1)If the user clicks "Yes, Change It", then simply close this top pop-up
      2)If the user clicks "No, Revert Back", then revert the file name field back to its prior value and close this top pop-up (this will probably require another small JavaScript snippet)
Photo of Prapoorna

Prapoorna

  • 120 Points 100 badge 2x thumb

Posted 2 years ago

  • 1
Photo of Mark DeSimone

Mark DeSimone, Official Rep

  • 11,050 Points 10k badge 2x thumb
Hi Prapoorna, this may be possible without using any script. The Action Framework in Skuid has grown to be very powerful, and it will be beneficial for you to learn about it even if you don't end up using it for your needs. Whether you use scripting or not though, I think the solution will take some work.

You'll definitely want to read about the file upload component and experiment with which fields are available for attachments. Extension may be available in Salesforce as its own field, if I remember correctly.

Step 2 could fire off a Model action that generates a popup whenever a condition is set to true. The condition could watch the file name field, and you may be able to use the "ends with" operator to compare text. 

In the popup, you would use a rich text field or a template to display the warning text, and a button set with the two choices (yes/no). Each button would fire off a different set of actions, depending on how things should be resolved. 

I hope this summary and the links provided will help you consider how you might approach building this tool. I would recommend trying to tackle one step at a time and link the elements together once you've gotten them pretty well built.
(Edited)