Image visible in interface but not in portal

Certified Senior Developer

Hello,

I have a portal which only has one interface. In the interface, I retrieve the data I need and store it in a local variable, I then use that local variable as the value for the document inside an imagefield component. In the interface, the data is successfully retrieved and is displayed in the imagefield component below. But in the portal, once I publish, the image is not visible. Does anyone know why that is? I already checked the service account permissions, I'll put them below as well.

Oh and also, "Register account" button doesn't work when I try to register a new account using the portal, even though in the process model, it does. I'm not sure if this also a service account permission problem or not

In interface, image is displayed successfully

In portal, there's not image

Code snippet

I retrieve the data from the record type and store it in a local variable

I display the image in the imagefield component

Service account permissions

Record types --> Viewer permission

Interface --> Viewer permission

Process model --> Initiator permissions

Document folder --> Viewer permissions

Any help is appreciated. Thank you!

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    You're trying to retrieve the document by ID, then show that document ID in a viewer in the Portal.

    This is something I'm not sure is compatible with Portals.  The way Portals currently work (as best as I understand it) is they are totally separate from most things in your appian installation with a bare few exceptions (like, recently, database queries), but all other objects and references, etc, are packaged up and installed on the "external" server that hosts the portal.

    Here you're trying to feed the interface an ID from a DB query, but then it's trying to just display that image by ID, even though the ID is an Appian FS document ID.  You need to consider at this point that the portal does not have direct visibility into the Appian FS at runtime, by design.

    I think the "supported" approach here would be to build a Web API that reaches the Appian filesystem and tries to request the document by ID, then display that locally.  I'm not sure it'll work but it might be worth a shot.

    Alternatively, if the number of "agreement" image files you have is pretty finite / small, you could potentially upload ALL of them to the portal, then use the retrieved document ID to decide (at runtime) which one you want to call.  Something like this where they end up in the portal's package would probably be the easiest approach, honestly.

  • 0
    Certified Senior Developer
    in reply to Mike Schmitt

    Thank you so much for this! As I am working in a limited environment, I don't think I can do the webAPI approach.

    How would you go about uploading all of the documents to the portal, since I've rarely worked with portals before and never took that approach? Thanks again!

  • 0
    Certified Lead Developer
    in reply to Tamara Saadeh
    How would you go about uploading all of the documents to the portal

    Presumably all of these documents exist as Appian objects.  How many are there?  If there are maybe 5, up to maybe 10, then no big deal.  If there are dozens or hundreds, then I would suggest alternate options instead of the following approach.

    You would need an individual constant for each image.  Alternatively if that's burdensome, a "document" type constant set to "multiple" that you add each image directly to, as long as the list will be fairly static over time, is manageable (just document which index each image resides at in the constant's list).  Then in your interface, you can use if() logic (or an a!match() statement) to manually check what the queried ID is, compare it against that value in the constant, then reference it directly. 

    (Before doing much work here, I'd suggest trying this approach with just a single image the first time, to make sure it'll even work).  If you're VERY lucky, then simply getting the images rolled into the precedents of the portal object might allow you to display them directly by ID - sadly i'm fuzzy on how this would work and haven't tried it myself yet.

  • 0
    Certified Senior Developer
    in reply to Mike Schmitt

    Ok that actually makes sense. I'll try that now.

    But what if the user agreement document keeps changing?

    Right now, we have it where if an admin chooses to upload a new user agreement document, the portal's user agreement document should retrieve the latest uploaded document and display it. Is there a way to dynamically change the value of the constant with the latest uploaded document each time an admin uploads one or no?

  • 0
    Certified Lead Developer
    in reply to Tamara Saadeh

    If it's going to be fairly un-static, then I'd consider looking into alternative approaches honstely.

    Now I must update with what I've just found in my own personal test (this is my CE 24.1 version - it'd be good if you can confirm your appian version for comparison?) - I had an image file that I'd added to the app package for my test portal (but not already otherwise referenced in the portal manually by any means) - I was able to add an image field using a!documentImage into my existing test form, and upon publication, it showed up on my form just fine.

    In yours, please try swapping out the queried value for an example manual document ID, just temporarily to see what happens.  There may be easier ways to accomplish your use case as long as things are done carefully.

  • 0
    Certified Senior Developer
    in reply to Mike Schmitt

    hmm, you're right. I used a manual ID for the document image and it worked, but the queried data isn't working. For now, I'll just replace it with a documentviewer which seemed to work fine but will try and figure out a solution later.

    One final question if you don't mind: another weird thing happening is that the form in the portal is not working when I click on "Register for account." I checked the process model and created a couple of user accounts by clicking on the "Start process for debugging" which worked.

    But for some reason in the portal, I click the "Register for account" button and it doesn't work. The service account is set to "initiator' permissions in the process models and yet it refuses to create a new user through the portal. Do you have any advice on what might be causing this?

    Thanks again

  • 0
    Certified Lead Developer
    in reply to Tamara Saadeh
    but the queried data isn't working

    This is going to seem silly, but how sure are you that it's getting a valid image id as a result?  Are you SURE they're always images?  Also, i'm not sure but it's possible the documentImage function has a funny reaction with arrays (which queried data is inherently) - so you can always try calling index(local!queriedData, 1) for instance.

    I click the "Register for account" button and it doesn't work.

    You didn't really specify where this goes wrong.  Does the process model launch or not?  If it launches, what happens internally - does it error out on a certain node?  Can you post a screenshot of the process instance?

  • 0
    Certified Senior Developer
    in reply to Mike Schmitt

    Right now, we're not testing it with real users so everything is happy path testing. But indexing into it is definitely a good idea, I'll keep that in mind once I go back to it, thank you!

    So when we fill out data in the form through the process model like below and click 'Register for account", the process works and a user is created

    But in the portal, filling out the information in the same form and clicking on "Register for account" doesn't work no matter how many times we press the button. We checked the server logs and there was nothing mentioning it

  • +1
    Certified Lead Developer
    in reply to Tamara Saadeh

    But what does the "register for account" button on the portal form do?  Does it launch a process?  If so, is it actually getting launched when you click it?

  • 0
    Certified Senior Developer
    in reply to Mike Schmitt

    Ok I see what you mean now. I think I wasn't adding a startProcess component into the saveinto parameter which seemed to fix the issue. Thanks so much for your input, it made me think about the issue and come up with the solution. You're the best.

    Have an awesome day!

Reply Children
No Data