Issue with Read Only

rss

Posted by Eax - Nov 18 ’15 at 10:07

Hello guys,

I have a problem with the readonly :

In a list A, i put some information (Compagny, etc...) in a new item.

In a list B, i create new element and take automatically all information from the item parent in list A and need to put them ReadOnly.

If i open a new item in List B without parent item, these field are not on read only.

It's ok, but when i tryed to save my item in List B with information from my parent item in list A, none informations was saved.

I try with the "function PreSaveItem" or "PreSaveAction" but doesn't work

Have you an idea about this ?

Best regards,

  • rostislav
    rostislav
    Moderator
    Member for: 6 years 8 months 14 days
    #1 by rostislav Nov 18 ’15 at 11:25

    How are the two lists linked? How are you retrieving the information from the parent list?

  • Eax
    Member
    Member for: 6 years 2 months 23 days
    #2 by Eax Nov 18 ’15 at 11:36

    With this  :

    fd.field('Compagny').value(window.top.fd.field('Societe').value());

  • rostislav
    rostislav
    Moderator
    Member for: 6 years 8 months 14 days
    #3 by rostislav Nov 19 ’15 at 05:13

    [#2]:

    Please, provide screenshots showing the problem (upload to some image sharing service and paste the URLs here). Also, I'll need to know:

    -again, how the lists are linked

    -how you are opening the child window

    -what type of field are Compagny and Societe.

  • Eax
    Member
    Member for: 6 years 2 months 23 days
    #4 by Eax Nov 19 ’15 at 06:36

    [#3]:

    Linked :

    (Identification field is ID Field)

    Parent list :

    Childlist :

    Newitem from childlist :

    And when i click on "Save", only "Imputation" is saved because is not "ReadOnly".

    by the way, this is the code i made for my childlist :

    //Affaire
    var strIdAffaire = fd.getSourceID();
    fd.field('Id_Affaire').value(strIdAffaire);
    alert(strIdAffaire)
    //Lecture seul
    if (!fd.field('Id_Affaire').value()){
    fd.field('Id_Affaire').readonly(false);
    fd.field('Societe').readonly(false);
    alert("dansmonif")
    }
    else {
    fd.field('Id_Affaire').readonly(true);
    fd.field('Societe').readonly(true);
    alert("dansmonelse")
    };
    //Societe
    //Societe
    fd.field('Societe').value(window.top.fd.field('Societe').value());
    //Imputation
    fd.field('Title').value(window.top.fd.field('Title').value());

    The 3 fields is  a simple line text field.

    Thank you

  • rostislav
    rostislav
    Moderator
    Member for: 6 years 8 months 14 days
    #5 by rostislav Nov 19 ’15 at 07:21

    [#4]:

    Aha, I got you. See the solution in the first answer in this thread http://forum.spform.com/forms-designer-for-sharepoint-20/required-readonly-field-gets-cleared-after-related-items-list-fo-25194/

  • Eax
    Member
    Member for: 6 years 2 months 23 days
    #6 by Eax Nov 19 ’15 at 08:38

    [#5]: Thank you !

    I try with this :

    fd.onsubmit(function() {
    if (!fd.field('Id_Affaire').value()) {
    fd.field('Id_Affaire').readonly(false);
    fd.field('Societe').readonly(false);
    return false;
    }
    else {
    fd.field('Id_Affaire').readonly(true);
    fd.field('Societe').readonly(true);
    alert("dansmonelse")
    return false;
    }
    return true;
    });

    But not working :( did something wrong ?

  • rostislav
    rostislav
    Moderator
    Member for: 6 years 8 months 14 days
    #7 by rostislav Nov 19 ’15 at 08:45

    [#6]:

    Just use the following snippet:

    fd.onsubmit(function() {
    	fd.field('Id_Affaire').readonly(false);
    	fd.field('Societe').readonly(false);
    	return true;
    });
    
  • Eax
    Member
    Member for: 6 years 2 months 23 days
    #8 by Eax Nov 19 ’15 at 09:00

    [#7]: My field aren't in readonly when i create a new item with it

    Any idea ?

  • rostislav
    rostislav
    Moderator
    Member for: 6 years 8 months 14 days
    #9 by rostislav Nov 19 ’15 at 09:22

    The message was removed by a forum moderator.

  • rostislav
    rostislav
    Moderator
    Member for: 6 years 8 months 14 days
    #10 by rostislav Nov 19 ’15 at 09:23

    [#8]:

    1. Use your code that you used before to set your fields as readonly or not readonly. This is unchanged.

    2. Add to that the snippet that I've posted above. What this snippet does is sets the fields to write mode just before submitting (saving) the form, which allows to save the data inside those fields. This is needed due to how browsers work: they don't submit data in readonly fields.

Displaying 1 to 10 of 11 messages
Previous12