Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.
SOLVED

Delete current veiwed page help!!!

Avatar

Level 2

Hi I've created a form that adds a new instance when i click on a button with the click script

"Mysubform.addinstanceManger.addInstance (1);"

This copies my complete form to a new page which is what i want it to do.

However when veiwed in on the web i want to create a delete button that will delete the current page the user is veiwing if they decide they want to.

example if the first form is filled out and they click the add new page and fill out the second form, and click again if they need to fill out another.

If now for example they have now created 4 pages and decide they want to delete say, page 2 or maybe page 3. but keep the other pages with information already entered. How do i create a button that deletes the current page they choose to delete.

Any detaiiled help would be greatly appreciated!!!!!! as i am new to scripting and LC.

1 Accepted Solution

Avatar

Correct answer by
Former Community Member

Very odd. I think I got it right this time.

View solution in original post

5 Replies

Avatar

Former Community Member

Take a look at the attached. The form includes a button 'removePageBtn' and the click event is as follows:

// form1.page.subform.removePageBtn::click - (JavaScript, client)

var i = this.parent.instanceIndex;

if (i == 0) {

     if (form1.page.instanceManager.count > 1) {

          form1.page.instanceManager.removeInstance(0);

     }

}

else {

     i = i + 1;

     form1.page.instanceManager.removeInstance(i);

}

Steve

Avatar

Level 2

Hi Steve thankyou for your help.

I tried your attached form and as a test I added three pages and typed a different name in the name fields for each form to distinguish them appart.

So for example the first form has a name of "Steve", second form has a name of "John" and third form has "Rick",

Now if i go to the second page/form and click "Remove This Page Button" the first form with the name of Steve has been deleted and not the second form of "john" where i clicked the button from. So is it possible to remove the page that i clicked to delete and have the others with their data, remain. ? again any help is appreciated.

Avatar

Former Community Member

Whoops. Something got busted. It was working. Let me take a look.

Steve

Avatar

Correct answer by
Former Community Member

Very odd. I think I got it right this time.

Avatar

Level 2

Thanks Stevie L you are the man.!!!

works great.

The following has evaluated to null or missing: ==> liqladmin("SELECT id, value FROM metrics WHERE id = 'net_accepted_solutions' and user.id = '${acceptedAnswer.author.id}'").data.items [in template "analytics-container" at line 83, column 41] ---- Tip: It's the step after the last dot that caused this error, not those before it. ---- Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)?? ---- ---- FTL stack trace ("~" means nesting-related): - Failed at: #assign answerAuthorNetSolutions = li... [in template "analytics-container" at line 83, column 5] ----