0 votes

Hi,

I'm trying to make some options in a "LOOKUPDROPDOWN" unselectable when editing a PUBL_CONT relation. I found this article from Stéphane but i'm facing the following two problems.

  1. I don't know how to replace the Entity with PUBL_CONT, don't think JsScriptsTRW.PUBL_CONT would work.

  2. The "LOOKUPDROPDOWN" is loading the data every time when you click on it, so a AfterLoaded() of the the form wouldn't help anyway.

Anyone there who can point me in the right direction?

Thanks in advance
Stefan

asked in Efficy/ Client side by (111 points)

1 Answer

+1 vote
Best answer

Hi Stefan,

Log into Designer and switch from lookup definition LOOKUPDROPDOWN to LOOKUP in the form named "Standard: Edit Relation Publication-Contact" for the STATUS field.

After this change (and making a new Efficy session), the status will be rendered as a native select. That will be easier to tweak with client side JS.

The macro to be used should be formed like this and be placed in MacroRelationCustom.txt:

JsScriptsRelationTRW.Publ.Cont, JsScriptsRelationTRW.Cont.Publ  {[
<script>
  console.log('test');
  function AfterLoaded() {
        alert('TEST');
    }
</script>
]}
answered by (7.4k points)
selected by
Hi Kristof,

thanks for your quick reply! We had a similar requirement in the training, but it was already the standard selectbox. :-) And the selectbox is located in the Entity context, which brings me back to question 1.

Where would i place the code? I think MacroEditSCustom.txt is the right file, but how would i name the "property"? JsScriptsTRW.Publ_Cont {[ ... ]} does not do the trick.

Best
Stefan
JsScriptsTRW.Publ.Cont, JsScriptsTRW.Cont.Publ {[
  // Your scripts
]}
Added the following code to the bottom of MacroEditSCustom.txt, logging off and on again, opened Publ_Cont in edit context, nothing happens.

JsScriptsTRW.Publ.Cont, JsScriptsTRW.Cont.Publ  {[
<script>
  console.log('test');
  function AfterLoaded() {
        alert('TEST');
    }
</script>
]}

I also tried JsScriptsTRW.Cont.Publ {[ .. ]} and JsScriptsTRW.Publ.Cont {[ .. ]}. Refresh Settings in the Admin Console didn't help as well.

Did i miss something?
I made a mistake, corrected the original answer
Thanks Kristof! Alert is working now. ;-)

But unfortunately i can't run the following line of code in that "context".
SetDisabledOptions("STATUS", <%RunScript("GetNotAllowedTypesArray", LookupKeyName="K_PUBL_STATUS")%>);

When i open the edit PublCont window, i retrieve the following error code:
Scripting Language is not specified

"Last" line in trace:  Call RunScript(=GetNotAllowedTypesArray, LookupKeyName=K_PUBL_STATUS)

Best
Stefan
A <%RunScript()%>  can only work if a <%LoadScript()%> tag was already evaluated , while parsing the page
Thanks Kristof, finally everything is working.
1,249 questions
1,519 answers
1,859 comments
328 users